17,377
社区成员
发帖
与我相关
我的任务
分享
create table test2(
name VARCHAR2(12),
idType VARCHAR2(20),
idDesc VARCHAR2(100),
CONSTRAINT test_ck_2 CHECK (
((idType = 'KK') AND (idDesc IS NOT null))
OR idType != 'KK'
)
);
--insert valid data
insert into test2 values ('Tracy','KK','sdf');
1 rows inserted
--insert invalid data
insert into test2 values ('Tracy','KK','');
Error starting at line 1 in command:
insert into test2 values ('Tracy','KK','')
Error report:
SQL Error: ORA-02290: check constraint (GBADMIN.TEST_CK_2) violated
02290. 00000 - "check constraint (%s.%s) violated"
*Cause: The values being inserted do not satisfy the named check
*Action: do not insert values that violate the constraint.