Oracle基本语法

约束条件

唯一键(unique):

constraint Constraint_name UNIQUE (columu),

               Constraint_name 约束名称   columu 字段名称

例子 :constraint emp_uk UNIQUE(empID);

查询表的约束条件 , select constraint_name ,constraint_type from user_constraints

where table_name ='表名';

主键(paimary key):

constraint constraint_name PAIMARY KEY (columu),

非空值约束条件查询

select constraint_name , constraint_type,search_condition from user_Constraints

where table_name = '表名';检查(check):

Constraint  constraint_name CHECK (condition)

外键(Foreign Key):

constraint constraint_name Foreign Key (column) references table_name(cloumn);

          references 参照至

 

添加约束条件:

Alter TABLE table ADD[ CONSTRAINT constraint] type (column)

例子:ADD constraint depart_empid_fk FOREIGN KEY(empid) REFERENCES EMP(empid);

 

启动约束条件 :

ALTER TABLE depart ENABLE constraint depart_empid_fk;

关闭约束条件:

ALTER TABLE depart  DISABLE constraint depart_empid_fk;

删除约束条件:

alter table depart drop constraint depart_empid_fk;

 

猜你喜欢

转载自17097220887.iteye.com/blog/2304300