【Oracle】表定义完成后再给字段加约束

表定义完了后给字段加约束比较常见,毕竟变化是唯一不变的。

1.加主键

alter table table_name add primary key(id);

2.加唯一性约束

alter table table_name add unique(code);

3.给number类型字段status加输入值约束

alter table table_name add check(status=1 or status=0);

4.给varchar2、nvarchar2字段prj加输入性约束

alter table table_name  add check(prj='oper' or prj='sql' or prj='api');

END

原文地址:https://www.cnblogs.com/heyang78/p/15472999.html