DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Indexes

  1. #1
    Join Date
    Jul 2001
    Posts
    93
    Hi,

    If I am given a choice creating a primary key on the table versus a unique index on the table what should be preferred.

    I am aware of the differences between the primary key and unique indexes.

    Eg:

    create table Test(T1 number not null, T2 varchar2(10),
    primary key(T1));

    or

    create table Test(T1 number unique not null, T2 varchar2(10));

    I have my entire schema with Primary Key indexes and not a single foreign key.

    Does Oracle create a different index structure for a primary key and unique constraints. Will there be any performance issues.


    Thanks in Advance



  2. #2
    Join Date
    Mar 2002
    Location
    Mesa, Arizona
    Posts
    1,204
    Just more typing in the second example because you'll have to create the primary key after you create the unique index.

    "I do not fear computers. I fear the lack of them." Isaac Asimov
    Oracle Scirpts DBA's need

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    index structure are the same since both are b-tree based

    you dont necesary need to create an unique index to enforce primary key, in 8i you can create a non-unique index then add PK to it by doing so when you disable the PK the index wont get dropped, this is an 8i feature mainly for Datawarehouse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width