|
Primary key 與Unique Key都是唯一性約束。但二者有很大的區(qū)別: 1、Primary key的1個或多個列必須為NOT NULL,如果列為NULL,在增加PRIMARY KEY時,列自動更改為NOT NULL。而UNIQUE KEY 對列沒有此要求。 2、一個表只能有一個PRIMARY KEY,但可以有多個UNIQUE KEY。 下面以測試說明: SQL> create table t (a int,b int,c int,d int); Table created. SQL> desc t A NUMBER(38) SQL> alter table t add constraint pk_t primary key (a,b); Table altered. SQL> desc t A |