Primary key and Unique index
2014-02-22 21:57
411 查看
SQL> create table t1(id1 char(2),id2 char(2),id3 char(2)); Table created. SQL> desc t1 Name Null? Type ----------------------------------------- -------- ---------------------------- ID1 CHAR(2) ID2 CHAR(2) ID3 CHAR(2) SQL> insert into t1 values('a',null,'a'); 1 row created. SQL> commit; Commit complete. SQL> select * from t1; ID ID ID -- -- -- a a SQL> alter table t1 add constraint PK_EMP primary key (id1,id2,id3); 2 add constraint PK_EMP primary key (id1,id2,id3) * ERROR at line 2: ORA-01449: column contains NULL values; cannot alter to NOT NULL SQL> create unique index t1_idx1 on t1(id1,id2,id3); Index created. SQL> insert into t1 values('a',null,'a'); insert into t1 values('a',null,'a') * ERROR at line 1: ORA-00001: unique constraint (SYS.T1_IDX1) violated
相关文章推荐
- Primary key and Unique index
- Unique Constraint, Primary Key and Unique Index
- ORA-02429: cannot drop index used for enforcement of unique/primary key
- Difference between Key, Primary Key, Unique Key and Index in MySQL
- mysql key primary key unique index index的区别
- ORA-02429: cannot drop index used for enforcement of unique /primary key
- ORA-02429: cannot drop index used for enforcement of unique/primary key
- What's different between INDEX and KEY in database
- Hibernate Id Generator and Primary Key
- mysql index and key
- key,primary key unique key的区别
- PRIMARY, INDEX, UNIQUE 这3种是一类
- MYSQL的索引类型:PRIMARY, INDEX,UNIQUE,FULLTEXT,SPAIAL 有什么区别?各适用于什么场合?
- MYSQL的索引类型:PRIMARY, INDEX,UNIQUE,FULLTEXT有什么区别?各适用
- 【Oracle问题集5】ORA-55622: DML, ALTER and CREATE UNIQUE INDEX operations are not allowed on table
- 集成GreenDao3,遇到PRIMARY KEY must be unique的问题解决
- PRIMARY KEY与 UNIQUE的区别?
- Differences between INDEX, PRIMARY, UNIQUE, FULLTEXT in MySQL?
- mysql primary key & unique key
- 【MonogDB】The description of index(三) Compose and unique Index