Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Primary Key/Unique Key?

Re: Primary Key/Unique Key?

From: Mike Carter <mike_at_delriotech.com>
Date: Tue, 7 Dec 1999 11:30:44 -0600
Message-ID: <Osb34.80366$5W2.2261248@news6.giganews.com>


This example works because Oracle doesn't handle NULL as a specific type = or value. For example:
Table TEST:
ID INTEGER
Name Char

The two records below are actually different from one another.

ID        Name
1          NULL
1          NULL


  Ivan <ivan_at_protek.ru> wrote in message = news:384D33F8.FFD91A47_at_protek.ru...
  Hi, All!
  You can test it:
    SQL> create table qq(n number primary key);

        Table created.

        SQL> insert into qq values(null); 
        insert into qq values(null) 
                    * 
        ERROR at line 1: 
        ORA-01400: mandatory (NOT NULL) column is missing or NULL during =
insert 
          

        SQL> drop table qq 
          2  ; 

        Table dropped. 

        SQL> create table qq(n number unique); 

        Table created. 

        SQL> insert into qq values(null); 

        1 row created. 

        SQL> insert into qq values(null); 

        1 row created. 

        SQL> select * from qq; 

                N 
        --------- 
          
          

        SQL> insert into qq values(1); 

        1 row created. 

        SQL> insert into qq values(1); 
        insert into qq values(1) 
                    * 
        ERROR at line 1: 
        ORA-00001: unique constraint (ABC.SYS_C001691) violated
       


  Ergo:
  unique <> primary

  Best regards,
  Ivan     

  Jurry wrote:

    I don't think there's really a difference.     A primary key in a relational database is always unique!

    Dave <none_at_nowhere.nothere.oops> schreef in artikel     <82ip3r$cuv$1_at_lure.pipex.net>...
> Whats the difference between making something
> a primary key and making something a unique key.
> From Oracles point of view that is.
> Dave
>
>
>
>
Received on Tue Dec 07 1999 - 11:30:44 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US