Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Primary Key ....
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 BortelReceived on Sat Mar 12 2005 - 07:20:30 CST