Mega Code Archive

 
Categories / Oracle PLSQL / Constraints
 

Violate constraints

SQL> SQL> create table t   2  ( x int,   3        constraint x_greater_than_zero check ( x > 0 )   4                   deferrable initially immediate   5  )   6  / Table created. SQL> insert into t values ( -1 ); insert into t values ( -1 ) * ERROR at line 1: ORA-02290: check constraint (SYS.X_GREATER_THAN_ZERO) violated SQL> SQL> set constraint x_greater_than_zero deferred; Constraint set. SQL> insert into t values ( -1 ); 1 row created. SQL> SQL> commit; commit * ERROR at line 1: ORA-02091: transaction rolled back ORA-02290: check constraint (SYS.X_GREATER_THAN_ZERO) violated SQL> set constraint x_greater_than_zero deferred; Constraint set. SQL> insert into t values ( -1 ); 1 row created. SQL> set constraint x_greater_than_zero immediate; set constraint x_greater_than_zero immediate * ERROR at line 1: ORA-02290: check constraint (SYS.X_GREATER_THAN_ZERO) violated SQL> SQL> drop table t; drop table t * ERROR at line 1: ORA-02091: transaction rolled back ORA-02290: check constraint (SYS.X_GREATER_THAN_ZERO) violated