Oracle Constraints
Related ArticlesOther ArticlesAdding constraints to the Existing Table
Dropping Constraints Dropping a Constraint with out constraint name. Constraint Codes Disabling and Enabling Constraints Precautions |
Integrity Constraints
implement business rules, to validate data, to ensure data integrity.
b) Column Level
a) Table Level Constraint <constraint_name> <constraint_type> [columns]; b) Column Level Constraint <constraint_name> <constraint_type> [condition]; Integrity Constraints are of 3 types:
a) Entity Integrity UNIQUE PRIMARY KEY b) Domain Integrity NOT NULL CHECK c) Referential Integrity FOREIGN KEY UNIQUE
Example: empno number(4) UNIQUE; Column Level Constraint Declaration: empno Number(4) UNIQUE, deptno Number(4) UNIQUE; Table Level Constraint Declaration: empno Number(4), deptno Number(4), ..... Constraint unq_empno UNIQUE( empno, deptno ); Primary Key
Example: empno Number(4) Primary Key; Column Level Constraint Declaration: empno Number(4) Primary Key; Table Level Constraint Declaration: empno Number(4),........ Primary Key (empno); Note: If the primary key is defined for combination of columns, it is called as "Composite Key". Not Null
Example: ename varchar2(20) NOT NULL; Note: Table level constraint is not allowed for NOT NULL constraint. Check
Example: 1. Sal NUMBER(7,2) CHECK ( sal>3000); 2. Gender CHAR(1) CHECK ( Gender IN ('M','F') ); Foreign Key
Master / Transaction Master / Slave
Transactions or Slave"
Examples: deptno number(4) references dept(deptno) UNIQUE; Precautions to be taken while dealing with Primary key and Foreign Key
|
Most ViewedOCA Syllabus
OCA Practice Questions OCA Practice Materials OCA Exam Online |