约束状态 . H e y; W( d
enable validate:是默认,新旧数据同时满足约束规则 % n+ h/ H/ ?: i! d
enable novalidate:旧数据可以不满足,检新插入的数据要满足约束 2 j7 [$ i2 g% U* D
disable validate:不允许在表上执行任何DML操作,主要用在分区表,对于主键和唯一约事,会删除相应的唯一索引,但约束状态任可用 2 T9 J, F* `- E2 M3 u' E. m
disable novalidate数据可不满足约束规则,对于主键和唯一约事,会删除相应的唯一索引,
, y: K d6 J; o7 F
( R+ ~% D, V2 o3 K7 i5 A# o约束常用语句
, X0 e8 k, W, G6 H' p create table t(i number,v mubmer not null) 9 U8 S4 c, A* z" x: ~
create table t(i number,v mubmer unique) ) ]/ M+ v3 G9 u, W8 e' X
create table t(i number constraint pk_i primary key,v number) 7 ?" \# m! R8 [4 w
create table t2(c number,d number,constraint fk_d foreign key(c),references t1(v)); # m6 a) B: z0 m; U' }& c
alter table t add constraint pk_i primary key (i) ; m+ M" A8 A& @. e% H4 N' K6 @. L
alter table t modify i not null; * z; n( a" y6 v( P x6 D
alter table t add constraint t_i unique(i)[(create index ind_name on t(i))];
" ?6 n% o& F- _% Y' Y+ } alter table t add constraint t_i check(i in (1,2,3,4,5));
& `' ]* y: l- f d. a' x2 D8 e# B alter table t disable novalidate constraint i # }- G! r9 V% ?6 ~1 V! ^. }" o
alter table t enable novalidate constraint check_i
2 \$ i( h9 x" D% I; t2 G1 p alter table t drop constraint i;
% H) J1 H9 w. U- f& d: U. `3 g& A alter table t drop primary key i; |