Multiple indexes using same columns on one table - is this doable?

Hi
I have a table like MyTab(a int, b int), and I am required to create a primary key index and a non-unique index on this table using columns (a,b) in a specific table space.
The back end database is Oracle 10g.
Here's what I have tried so far, needless to say, unsuccessfully.
Alter Table MyTab
Add Constraint c_1 primary key (a, b)
Using Index (Create index mytab_idx on MyTab(a, b))
Using index tablespace results_index
So my question are:
1. is this is possible? if so, what is the correct syntax.
2. assuming it is possible, has anyone used this sort of construct before? it appears to be conflicting and inconsistent to me.
Many thanks, and kind regards,
Naran

Naran H wrote:
Hi
I have a table like MyTab(a int, b int), and I am required to create a primary key index and a non-unique index on this table using columns (a,b) in a specific table space.
The back end database is Oracle 10g.
Here's what I have tried so far, needless to say, unsuccessfully.
Alter Table MyTab
Add Constraint c_1 primary key (a, b)
Using Index (Create index mytab_idx on MyTab(a, b))
Using index tablespace results_index
You can't have the unique and non-unique indexes in place at the same time, but you can have the non-unique index supporting the unique (PK) constraint.
I guess your problem is that you don't want to have an interval of time where you have dropped the existing unique index while you create the replacement.
The only current way I can think of for getting from:
unique index(a,b)
to
non-unique index(a,b) with PK constraint (a,b)
without having a point in time where bad data can appear, and with minimal locking is:
create unique index (b,a) online;
drop index (a,b);
create non-unique index(a,b) online;
add primary key using index (a,b) enabled, novalidate
validate primary key
drop index (b,a)Regards
Jonathan Lewis

Similar Messages

  • Indexes with multiple columns v/s multiple indexes with single column

    Hi Everyone,
    I have a table with below structure
    Create Table Test_Table
    Col1 int,
    Col2 int,
    Col3 int,
    Col4 int,
    Col5 int,
    Col6 int,
    Col7 int,
    Col8 bigint
    Col9 money
    Col10 money
    Now this table is being used in various reports. Since reports need various data, the filter clause for the report’s have various combination of table columns
    Example, Report 1 can have query like
    Select * from Test_Table where col1 = @val1
    Report 2:
    Select * from Test_Table where col1 = @val1 and col2 >=@val2
    Report3:
    Select * from Test_Table where col1 = @val1 and col2 >=@val2 and col3 =@val3 and col4 in(@val4)
    Report4:
    Select * from Test_Table where col1 = @val1 and col2 >=@val2 and col4 = @col4
    And many more combinations.
    Currently the table has many combinations of indexes
    Index1: col1, col2
    Index2: Col2
    Index3: col1, col2, col4
    Index4: col3 include (col9)
    Index5: col1, col2, col3, col4, col9
    Now I am into a performance issue where I have to create one more index with a slight variation from the existing combination of columns.
    Can you please let me know instead of having these various combination of indexes can I create multiple indexes on individual columns.
    Considering the above 4 examples which I have given for 4 reports, if I create 4 indexes separately on 4 individual columns col1, col2, col3, col4 will it be effective on all4 reports?
    Please suggest me the best way to create indexes on this table
    Thanks in advance,
    Raksha

    Do you really need to bring all columns ? Do not use SELECT *.
    Just a guess try index on col1, col2, col3, col4
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to update software on multiple iPhones using same iTunes account?

    How to update software on multiple iPhones using same iTunes account?

    SeanB15 wrote:
    Here are more details on my situation which should help clarify things...
    I purchased three iPhone 4 models back when they first came out (for my family) that all share the same iTunes account for access to apps and music, but each phone/user still has his/her custom contact list, email accts, and select lists of apps and music from the one iTunes acct library.  The problem is (as I understand it) that I can only update the software on one of the three iPhones – the primary phone I used to setup the iTunes acct without wiping out the separate contact lists, etc. As it stands today... the first (primary) iPhone associated with the iTune acct has been updated with the latest software version 5.1.1 and sync'd up with all the apps, music, etc from the one iTune acct, while the other two iPhones are still running on the original software version 4.0.2 and are experiencing problems now. I was advised by AT&T back in January that it would be necessary to setup separate iTunes accts for the second and third iPhones in order to receive system updates and still be able to manage separate contact lists, etc. If I go this route, I assume we will lose all the apps on phones #2 and #3 that we have been "sharing"... correct? Since this AT&T advice was prior to iCloud coming out, would iCloud be a better solution or at least part of the solution? I really don't yet understand how iCloud works. Hopefully, one of you can help me??
    we have 2 iphone 4's synced to the same itunes account for apps and music since the day we bought them, but each has a different icloud acct. they have both been updated on the same itunes account with every update that has come out since we bought them in december of 2010. nothing on either phone has ever been lost or duplicated. having said all that, maybe i'm missing something here, but we have had no problems. we do have itunes setup to sync manually. i do believe i'm a piker compared to lawrence finch, but i'm just telling you what happens in my house. maybe check with apple? is there a store near you?

  • Hide a column in one table view but show it in another

    I need to hide a column in one tables view but show it in another table view in the same report. Is this possible?
    Any help on this is appreciated.
    Edited by: VNC on Jan 11, 2010 9:26 AM

    Hi VNC,
    If you're crafty with javascript, you could probably write a script that would set the CSS property DISPLAY to NONE to hide the column in the table view you didn't want but leave it there in the view you did want.
    -Joe

  • Print multiples of the same image on one paper. I tried to change the layout to 9 per page, but it's only showing up and printing one per page, though it is the size i would like. But only one image is showing up as opposed to 9

    I'm trying to print multiples of the same image on one paper. I tried to change the layout to 9 per page, but it's only showing up and printing one per page, though it is the size i would like. But only one image is showing up as opposed to 9. HELP!!Version 7.0 (826.4)
    I'm using Preview Version 7

    Hello @kgingeri1, 
    Welcome to the HP forums.
    If you have sent a test print via ePrint, and experience this issue, i would call the Cloud Services department.
    If ePrint works fine, it is definitely a Google Cloud Print issue.
    Also, when you print from your android device, are you using Google Cloud print or the HP ePrint app?
    Please call our Cloud Services at 855-785-2777.
    If you live outside the US/Canada Region, please click the link below to get the support number for your region. http://www8.hp.com/us/en/contact-hp/ww-phone-assist.html
    Hours:
    Mon-Fri. 8am - 11pm, Sat. 9am-8pm - EST
    Mon-Fri. 7am - 10pm, Sat. 8am-7pm - CST
    Mon-Fri. 6am - 9pm, Sat. 7am-6pm - MST
    Mon-Fri. 5am - 8pm, Sat. 6am-5pm - PST
    Aardvark1
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!

  • How can I print multiple copies of same photo onto one page on iPhoto 9.5.1?

    How can I print multiple copies of same photo onto one page on iPhoto 9.5.1? I was able to do it on the old iPhoto, but can't seem to be able to do it on the new iPhoto. Grrr...

    Photos does the same thing.... Only workaround I can come up with is to create a template in Pages and copy & paste.

  • Need to compare values in two columns of one table against values in two columns in another table

    Hi, as the title reads, I'm looking for an approach that will allow me to compare values in two columns of one table against values in two columns in another table.
    Say, for instance, here are my tables:
    Table1:
    Server,Login
    ABCDEF,JOHN
    ABCDEF,JANE
    FEDCBA,SEAN
    FEDCBA,SHAWN
    Table2:
    Server,Login
    ABCDEF,JOHN
    ABCDEF,JANE
    FEDCBA,SHAWN
    In comparing the two tables, I'd like my query to report the rows in table1 NOT found in table2. In this case, it'll be the 3rd row of table one:
    Server,Login
    FEDCBA,SEAN
    Thanks.

    create table Table1([Server] varchar(50), Login varchar(50))
    Insert into Table1 values ('ABCDEF','JOHN'),('ABCDEF','JANE'),('FEDCBA','SEAN'),('FEDCBA','SHAWN')
    create table Table2([Server] varchar(50), Login varchar(50))
    Insert into Table2 values ('ABCDEF','JOHN'),('ABCDEF','JANE'), ('FEDCBA','SHAWN')
    select [Server] ,Login from Table1
    Except
    select [Server] ,Login from Table2
    select [Server] ,Login from Table1 t1
    where not exists(Select 1 from Table2 where t1.[Server] = t1.[Server] AND Login=t1.Login)
    drop table Table1,Table2

  • Constructing Calculated Measures in MDX for different measures using same columns in a fact table

    Hello,
    i have a fact table with 2 columns corresponding to dimensions Dim1, Dim2. In the same table i have 4 other columns Value_Type(int), INT_VALUE(int), FLOAT_VALUE(float), TEXT_VALUE(string). There are a number of measures which are identified by Value_Type and
    depending on their nature could be written in one of the 3 columns (INT_VALUE(int), FLOAT_VALUE(float), TEXT_VALUE(string)) Let's say Measure1 with Measure_Type=1 is age, 2 is account balance and 3 is Name for clarity. There could be other measure types that
    use these 3 same columns for data. So the sample fact table looks like this
    Dim1 Dim2 Measure_Type INT_VALUE FLOAT_VALUE TEXT_VALUE
    10 10 1 25
    10 10 2 2000,34
    10 10 3 John
    10 20 1 28
    10 20 2 3490,23
    10 20 3 Frank
    My task is to write an MDX query for each Dim1, Dim2 combination which returns all 3 measures in the same row. The idea is to construct a calculated member for each Measure that returns value from the right field. For example for Measure1 we take INT_VALUE
    with measure_type=1. The problem is i don't know how to construct MDX query for these calculated members. Can you please help me?
    So my final goal is to write an MDX query that returns all measures in one row for each set of Dim1, Dim2
    SELECT [Measure1], [Measure2], [Measure3] ON COLUMNS,
    NON EMPTY [Dim1].[Dim1].[Dim1].Members*[Dim2].[Dim2].[Dim2].Members ON ROWS
    FROM [Cube]
    Dim1 Dim2 Measure1 Measure2 Measure3
    10 10 25 2000,34 John
    10 20 28 3490,23 Frank

    Hi Kosmipt,
    I would combine the "INT_VALUE", "FLOAT_VALUE" and "TEXT_VALUE" columns into one with STRING data type for the fact table. And there should be one dimension to store the Measure_Type informations. Then in cube, you can write MDX scope for every one of
    "Measure_Type" dimension members. For example,
    scope(
                [Measures].[M]
        [DimMType].[MType].&[1]= CINT([Measures].[M]);                                                                                                                             
    end scope;
    Once the cube is built by the above way, you can write MDX like something like the following to achieve your purpose.
    WITH member [Measures].[Measure1] AS ([DimMType].[MType].&[1],[Measures].[M])
             member [Measures].[Measure2] AS ([DimMType].[MType].&[2],[Measures].[M])
             member [Measures].[Measure3] AS ([DimMType].[MType].&[3],[Measures].[M])
    thanks,
    Jerry

  • Update column in one table from another

    I've got two tables:
    t1:
    con_num
    con_code
    ex
    elin
    addressee
    a few other columns
    t2:
    con_num
    con_code
    elin
    addressee
    contact
    a few other columns
    I just got about 300 rows into t2 using sqlloader, and now I need to use t2 to update t1. t1 will have 3 rows per ex||elin, but t2 can have more or less rows per elin (which is the same as ex||elin in t1). If t2 has 4 rows per one elin, then that is 4 distinct pieces of data, and I need to make sure that t1 reflects 4 rows in its ex||elin, each containing the addressee||contact from t2. So I'll need to add a row to t1, as well as update 3 rows. Is this possible with just SQL, or do I need to write PL/SQL?
    The following is the code I've been trying:
    update t1
    set t1.addressee =
    (select addressee from t2
    where t2.con_num = 'number'
    and t1.con_code = t2.con_code
    and t1.ex ||t1.elin_num = t2.elin_num)
    This code is not correct, it returns more than one row from t2. Also, I'd need to concatenate contact onto addressee with a space in the middle, not just addressee, into t1.addressee.
    Any ideas, pointers?
    Thanks!

    Forgot some info: Ora8.1.5 on win2kpro. Also, I was wanting to combine addressee||contact in the insert/update statement to differentiate one addressee from another in t1 after the data is inserted. We can have several addressees that are the same, but each one goes to a different contact for each record.
    Thanks!

  • Multiple Apps using same security system -  Attn: Frank

    Hi Frank:
    Based on what you suggested for a scenario with different apps/databases using one "application_users", "application_roles" tables and one "system-jazn-data.xml" file, does the following setup sound right?
    (1) APPLICATION_ROLES table
    Add an additional column "APPLICATION_REALM". This will have "app_one_realm", "app_two_realm" etc.
    (2) System_jazn_data.xml
    <application>
    <name>current-workspace-app_one</name> (***App One wrkspace****)
    <login-modules>
    <login-module>
    <class>oracle.security.jazn.login.module.db.DBTableOraDataSourceLoginModule</class>
    <control-flag>optional</control-flag>
    <options>
         <option>
         <name>data_source_name</name>
         <value>jdbc/BDTestDS_App_One</value> (***Points to connection for App One. Does this sound right?****)
    </option>
    <option>
    <option>
    <name>realm_column</name> (***is this correct?**)
    <value>application_realm</value> (**Is this correct?***)
    </option>
    </options>
    </login-module>
    </login-modules>
    </application>
    <application>
    <name>current-workspace-app_two</name> (****App Two wrkspace. Make sense*** )
    <login-modules>
    <login-module>
    <class>oracle.security.jazn.login.module.db.DBTableOraDataSourceLoginModule</class>
    <control-flag>optional</control-flag>
    <options>
         <option>
         <name>data_source_name</name>
         <value>jdbc/BDTestDS_App_Two</value> (***Does this sound right? Coonection for App Two*****)
    </option>
    <option>
    <name>realm_column</name> (***is this correct?***)
    <value>application_realm</value> (***Is this correct?***)
    </option>
    </options>
    </login-module>
    </login-modules>
    </application>
    (3) system-application.xml (Points to absolute path for system-jazn-data.xml)
    <jazn provider="XML" location="<absolute address>/system-jazn-data.xml" default-realm="jazn.com"/>
    (4) jazn.xml (Points to absolute path for system-jazn-data.xml)
    <jazn
    location="<Absolute address>/system-jazn-data.xml"
    default-realm="jazn.com">
    </jazn>
    (5) I am not clear about your comment "Regarding Application Context when assigning roles to a J2EE authenticase case see jaassec/index.htm doc" Are you talking about something in the web.xml for each app?
    How does (a)
    <option>
    <name>realm_column</name>
    <value>application_realm</value>
    </option>
    in "system-jazn-data.xml"
    and (b) "APPLICATION_REALM" in APPLICATION_ROLES table
    and (c)      
    <application>
    <name>current-workspace-app_one</name>
    </application>
    <application>
    <name>current-workspace-app_one</name>
    </application>
    in "system-jazn-data.xml" all tie in?
    In other words, how are the roles tied to the appropriate application context? Each app needs to know its role?
    Thanks

    Hi,
    please note that application_realm only works with the LoginModule provided with the document. It doesn't work with the OC4J oracle.security.jazn.login.module.db.DBTableOraDataSourceLoginModule. Note that the how-to document I pointed you to explains the use of custom LoginModules by example of custom login modules I wrote.
    The way it works is that the application_realm if provided is used when querying the application specific roles. If a realm is not provided then all roles are queried for the user.
    Frank

  • Multiple users using same email account

    I'm the computer tech for a volunteer fire department. We have multiple officers using this computer and each one wants access to the same email account under their personal user accounts. Can this be done?

    You just need to "move" the profile to a common access location.
    http://kb.mozillazine.org/Moving_your_profile_folder_-_Thunderbird

  • How to Select data using same column name from 3 remote database

    Hi,
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.
    Ex.
    SELECT *
    a.name, b.status, SUM(b.qty) qantity, MAX(b.date) date_as_of
    FROM
    *((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)a,*
    *(table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)b)*
    WHERE b.dept = 'finance'
    AND a.position = 'admin'
    AND a.latest = 'Y' AND (b.status <> 'TRM') AND b.qty > 0;
    GROUP BY a.name, b.status ;
    NOTE: the bold statements is just an example of what I want to do but I always gets an error beacause of ambiguous columns.
    Thanks in advnce. :)
    Edited by: user12994685 on Jan 4, 2011 9:42 PM

    user12994685 wrote:
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.Invalid. This does not make sense and breaks all scope resolution rules. And whether this is in a single database, or uses tables across databases, is irrelevant.
    Each object must be uniquely identified. So you cannot do this:
    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a3 objects cannot share the same alias. Example:
    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
    ERROR at line 1:
    ORA-00907: missing right parenthesisYou need to combine the objects - using a join or union or similar. So it will need to be done as follows:
    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
    ERROR at line 1:
    ORA-00918: column ambiguously definedHowever, we need to have unique column names in a SQL projection - so the join of the tables need to project a unique set of columns. Thus:
    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    DUM DUM
    X   X
    SQL> I suggest that you look closely at what scope is and how it applies in the SQL language - and ignore whether the objects referenced are local or remote as it has no impact to fundamentals of scope resolution.

  • Multiple logons using same Logon Manager Splash Screen

    I have an web application set up in Logon Manager where the user profile is set to login as a simple user with matching credentials. I also want the person to login to the same web page at the same login splash screen using different credentials as administrator. Can this be done. I am new to this so all help id welcomed.

    Many questions, many answers. :-)
    Yes, Rich, they would need to install the multiserver version
    for you to see that Enterprise Manager option in the CF Admin. But
    no, they would not need to uninstall the Server deployment (what
    you did) to add the Multiserver deployment. They can co-exist
    (though it's not something most would typically do).
    The best news for you is that, yes, they can indeed just
    setup a second site on their web server, and have that also point
    to the one CF Server deployment you have installed. That is, of
    course, assuming they run a web server that supports multiple
    sites. If it's Apache, you're good. If it's Windows, then as long
    as its Windows Server 2003 (or 2008, or Vista), you're good, too.
    (Just for completeness, for other readers, XP does not let you run
    more than one site at a time.)
    If during the installation of CF you told it to have ALL
    sites in the web server run with CF, you need do nothing more than
    create the new site. It should immediately be able to run CF pages.
    If instead you told it to only link CF to one site, then you'll
    need to run the web server configuration tool again. You can do
    that manually, even after the installation. See the CF Admin and
    Config docs for more on that, as well as on this very question. (I
    realize many like to just run stuff and hope that the interface is
    clear enough, but as this question shows, for some things anyone
    installing CF will be well-served by looking over that often-missed
    manual.)
    Hope that helps, Rich. It's not an RTFM answer. :-) Just
    saying that if you need more than what I've said, it is in the
    manual. Still, I'll be happy to answer follow ups if I can.

  • How to insert records with LONG RAW columns from one table to another

    Does anybody know how to use subquery to insert records with columns of LONG RAW datatype from one table to another? Can I add a WHERE clause in the subquery statement? Thanks.

    Insert into ... Select statements are not supported for long or long raw. You will have to either use PL/SQL or convert your long raw to blobs.

  • Compare three columns within one table. Help!

    Hi All
    I had a post up about this yesterday but I didnt have much luck and im still really stuck on this so if there is anyone who has any idea please help me.
    I have three columns A,B,C within the one table. Column A may contain a value that is in Column B so if this is the case I need to enusre that it is not brought back in the query. I have tried using a minus function but it is not working very well. Probably because i am doing it wrong.
    So basically I need the query to
    Compare
    (A) Column A with Column B - If a value is present in column B I want to minus it/remove it from Column B
    (B) Column A with Column C - If a value is present in column C I want to minus it/remove it from Column B
    (C) Column B with Column C - If a value is present in column C I want to minus it/remove it from Column B
    OUTPUT AT PRESENT
    COL A COLB COLC
    12345 45666 78888
    45666 78888 66666
    66662 12345 37891
    Desired Output
    COL A COLB COLC
    -------- 45666 78888
    -------- -------- 66666
    66662 12345 37891
    Any help with this would be really appreciated
    Thanks

    SQL> select * from poles;
            P1         P2         P3
           123        101        123
           456        123        456
           789        456        999
    SQL> select decode((select count(*)
      2                from poles
      3                where p2 = p.p1
      4                or p3 = p.p1),0,p1) p1,
      5          decode((select count(*)
      6                from poles
      7                where p3 = p.p2),0,p2) p2,p3
      8  from poles p;
            P1         P2         P3
                      101        123
                                 456
           789                   999                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Error 6 occurred at Open/Creat​e/Replace File in NI_Excel.l​vclass:Sav​e Report to

    I have an application that works on LV60 and when run in LV86 I get the following error: Error 6 occurred at Open/Create/Replace File in NI_Excel.lvclassave Report to File.vi->SWF001 Test.vi Possible reason(s): LabVIEW: Generic file I/O error. ======

  • What's wrong with usage time of my iphone

    i just checked usage of call time on my iphone4 and surprisingly found out that my current period of call time is 4,294,963,694 day and lifetime is 4,294,963,694 day. i just saved screen shot. i'm just curious anyone have similar usage time?

  • How do i get an audio book to show the progress bar?

    I want to get back to a specific point in an audio book to listen over again without having to listen to an entire chapter. I used to be able to drag the bar that appeared under the title of the book, but that bar is not there any more. I have set it

  • Custom screen in BBP_CUF_BADI

    Hi, I know that this topic was discuss a million time on the forum, but I still didn't get how to put my customer fields in customer screen. I append the structures as it's describe oss note 458591 and 672960 and use badi bbp_cuf_badi. Everything is

  • How to download midlet in SDK from tomcat server on localhost

    how to download midlet OVER THE AIR in Java ME SDK 3 from tomcat server running on localhost THANKS!