Friday, February 18, 2011

Common Errors while performing DML Operations on a table.

Primary key  Constraints
Equivalent to a unique constraints, both sets of rules apply.
ORA-00001: unique constraint (SCOTT.PK_DEPT) violated


Foreign key Constraints
INSERT and UPDATE on the child table: the value must exist in the parent table.
ORA-02291: integrity constraint (SCOTT.FK_DEPTNO) violated - parent key not found
UPDATE and DELETE on the parent table,
there must be no dependent rows in the child table.
ORA-02292: integrity constraint (SCOTT.FK_DEPTNO) violated – child record found

Not null Constraints
INSERT and UPDATE: cannot insert without a value, or modify the value to null.
ORA-01400: cannot insert NULL into (“SCOTT”.“EMP”.“EMPNO”)

Unique Constraints
INSERT and UPDATE: cannot have any value that already exists in the table. 
Multiple nulls are permitted.
ORA-00001: unique constraint (SCOTT.PK_DEPT) violated