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

Thread: sql queries

  1. #1
    Join Date
    Feb 2002
    Posts
    7
    Hello everybody,
    please tell me what is the potential difference between a column declared as
    "primary key"
    and
    "not null unique"

    thank you all
    akber
    Vidhipariprashnena Sevaya
    (sanskrit an Indian Language means
    "Educate yourself to serve others")

  2. #2
    Join Date
    May 2001
    Location
    San Francisco, California
    Posts
    511
    When you define a primary key, oracle creates a key index. And you will have just one constraint instead of two. Furthermore, foreign key references are not allowed on a column unless defined as a primary key.
    Remember the Golden Rule - He who has the gold makes the rules!
    ===================
    Kris109
    Ph.D., OCP 8i, 9i, 10g, 11g DBA

  3. #3
    Join Date
    Feb 2002
    Posts
    7

    Unhappy

    Dear Kris,
    Thank you for you reply.
    Please note that i could create a reference to one table from another table without declaring one column as primary key. I declared a column as "unique" and could make a reference to this table from another table successfully as shown below

    create table a(aa number unique);
    create table b(bb number references a(aa));

    So by declaring as "unique not null" also will do the same job. Since 'aa' is declared as unique, a unique index is created by default. So the difference comes only in two constraints vs single constraint.

    What difference it makes to database performance when a column declared as single against two constraints

    Please reply
    Thank You
    Akber
    Vidhipariprashnena Sevaya
    (sanskrit an Indian Language means
    "Educate yourself to serve others")

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