17,377
社区成员
发帖
与我相关
我的任务
分享
SQL> create table t ( id int , constraint ck_t check(id between 10 and 100));
Table created
SQL> alter table t add constraint ck_t1 check(id between 5 and 200);
Table altered
SQL> alter table t add constraint ck_t2 check(id between 20 and 80);
Table altered
SQL> alter table t add constraint ck_t3 check(id between 200 and 300);
Table altered
SQL> insert into t values(201);
insert into t values(201)
ORA-02290: 违反检查约束条件 (OA20.CK_T2)
SQL> insert into t values(43);
insert into t values(43)
ORA-02290: 违反检查约束条件 (OA20.CK_T3)
SQL> insert into t values(255);
insert into t values(255)
ORA-02290: 违反检查约束条件 (OA20.CK_T2)
SQL>
1、我创建约束是没有问题的。oracle文档里没有明确说明约束是有个数限制的。
2、多次测试结果,约束同时生效,执行顺序是由下及上。即最后一个约束先做检查,然后是后数第二个,以此类推
3、删了重建吧。
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as basp
SQL>
SQL> create table t ( id int , constraint ck_t check(id between 10 and 100));
Table created
SQL> alter table t add constraint ck_t1 check(id between 5 and 200);
Table altered
SQL> alter table t add constraint ck_t2 check(id between 20 and 80);
Table altered
SQL> alter table t add constraint ck_t3 check(id between 200 and 300);
Table altered
SQL>
11G下没问题哦~~