一、创建唯一性约束:
alter table 表名 add constraint 约束名称 unique (列名1、列名2..)
查表:
SQL> desc customer;
Name Type Nullable Default Comments
---------------- ------------ -------- ------- --------
CUSTOMER_ID NUMBER
CUSTOMER_NAME VARCHAR2(20) Y
CUSTOMER_PHONE VARCHAR2(20) Y
CUSTOMER_ADDRESS VARCHAR2(50) Y
添加唯一性约束:
SQL> alter table customer add constraint unq_customer unique (customer_name,customer_phone);
?
二、修改唯一性约束:
1.删除
alter table customer drop constraint unq_customer;
2.重命名
alter table customer rename constraint unq_customer to unq_cst;
3.禁用、启用
alter table 表名 disable/enable constraint 约束名称;