当约束条件比较简单时
SQL> alter table emp add constraints ch_sal check(sal > 0); Table altered
当约束条件特别复杂时
SQL> alter table emp add constraints ch_hiredate check (hiredate >= sysdate); ORA-02436: 日期或系统变量在CHECK约束条件中指定错误
可以使用加了WITH CHECK OPTION关键字的VIEW来达到目的
SQL> INERT INTO 2 (SELECT empno, ename, hiredate 3 FROM emp 4 WHERE hiredate <= SYSDATE WITH CHECK OPTION) 5 VALUES 6 (9999, 'test', SYSDATE+1); ORA-01402: 视图WITH CHECK OPTION where 子句违规