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 ....

Re: Primary Key ....

From: Frank van Bortel <fvanbortel_at_netscape.net>
Date: Sat, 12 Mar 2005 14:20:30 +0100
Message-ID: <d0uq60$ce4$1@news5.zwoll1.ov.home.nl>


Ariji Chatterjee wrote:
> Dear Faculties,
> Here I have created a table in two manner ..
> ===================================
> SQL> create table Test
> 2 (
> 3 PK number(10,0) not null,
> 4 Name varchar(10)
> 5 );
>
> Table created.
>
> SQL> Alter table Test add constraint UK_Con Unique(PK);
>
> Table altered.
>
> Here Number of contraints is TWO.
> ===================================
> SQL> drop table test
> 2 /
> Table dropped.
>
> SQL> create table Test
> 2 (
> 3 PK number(10,0) primary key,
> 4 Name varchar(10)
> 5 );
>
> Table created.
>
> Here Number of contraints is ONE.
> ===================================
> Both the case "PK" column is exist.
> In the first scenario "PK" column can called as
> primary key ? Even if it is not declared as "primary key"?
> Thanks in advance.
> Regards
> Arijit Chatterjee
>

No.

For one, your unique constraint allows NULLs, a Primary Key does not (try creating a table with a NULL column, or do a describe of your table Test after your second example, above: you will see PK is NOT NULL, even though not specified, and thus NULLable (by default). The primary key constraint ALTERS the NULL column to a NOT NULL column)

-- 
Regards,
Frank van Bortel
Received on Sat Mar 12 2005 - 07:20:30 CST

Original text of this message

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