Professional Documents
Culture Documents
Constraint 3
Constraint 3
Continue
By.. Deepak Malusare
Database Programming with SQL
Managing Constraints
By : Deepak Malusare
Objectives
By : Deepak Malusare 3
Purpose
By : Deepak Malusare 4
Purpose
By : Deepak Malusare 5
Managing Constraints
By : Deepak Malusare 6
Managing Constraints
By : Deepak Malusare 7
The ALTER Statement
By : Deepak Malusare 8
Adding Constraints
By : Deepak Malusare 9
Adding Constraints Example
DEPARTMENTS - Parent
DEPARTMENT_ID DEPT_NAME MANAGER_ID LOCATION_ID
90 Executive 100 1700
110 Accounting 205 1700
190 Contracting - 1700
EMPLOYEE - Child
EMPLOYEE_ID FIRST_NAME LAST_NAME DEPARTMENT_ID
100 Steven King 90
101 Neena Kochhar 90
102 Lex De Haan 90
205 Shelley Higgins 110
206 William Gietz 110
By : Deepak Malusare 10
Adding Constraints Example
DEPARTMENTS - Parent
DEPARTMENT_ID DEPT_NAME MANAGER_ID LOCATION_ID
90 Executive 100 1700
110 Accounting 205 1700
190 Contracting - 1700
EMPLOYEE - Child
EMPLOYEE_ID FIRST_NAME LAST_NAME DEPARTMENT_ID
100 Steven King 90
101 Neena Kochhar 90
102 Lex De Haan 90
205 Shelley Higgins 110
206 William Gietz 110
By : Deepak Malusare 11
Adding Constraints Conditions
By : Deepak Malusare 12
Why Enable and Disable Constraints?
By : Deepak Malusare 13
Dropping Constraints
By : Deepak Malusare 14
Dropping Constraints
By : Deepak Malusare 15
Disabling Constraints
By : Deepak Malusare 16
Disabling Constraints
By : Deepak Malusare 17
Using the DISABLE Clause
• You can use the DISABLE clause in both the ALTER TABLE
statement and the CREATE TABLE statement.
CREATE TABLE copy_employees
( employee_id NUMBER(6,0) PRIMARY KEY DISABLE,
...
...);
By : Deepak Malusare 18
Using the CASCADE Clause
By : Deepak Malusare 19
Enabling Constraints
• You can use the ENABLE clause in both the CREATE TABLE
statement and the ALTER TABLE statement.
By : Deepak Malusare 20
Enabling Constraint Considerations
By : Deepak Malusare 21
Cascading Constraints
By : Deepak Malusare 22
Cascading Constraints
By : Deepak Malusare 23
When CASCADE is Not Required
By : Deepak Malusare 24
Viewing Constraints
By : Deepak Malusare 25
Viewing Constraints
By : Deepak Malusare 26
Query USER_CONSTRAINTS
By : Deepak Malusare 27
Terminology
By : Deepak Malusare 28
Summary
By : Deepak Malusare 29
By : Deepak Malusare