SP 23 24 Lecture10 IDB
SP 23 24 Lecture10 IDB
Introduction to Database
Lecture 11:
Data Constraints & Edit Constraints
Learning Objectives
2
To know about:
Data Constraints
Edit Constraints
Data Constraints
3
Syntax:
<col><datatype>(size)
not null
DEFAULT Constraints
7
Syntax:
<col><datatype>(size) unique;
PRIMARY KEY Constraints
9
Syntax:
1. Column level: <colname><datatype>(size)
primary key
Or,
<colname><datatype>(size) CONSTRAINT
<constraint name> PRIMARY KEY
Table level:
CONSTRAINT <constraint_name>
FOREIGN KEY (<col_name>)
REFERENCES
<parent_table_name>(<parent_table_column_
name>)
CHECK Constraints
13
Syntax:
alter table <table> drop constraint
<constraint_name>;
Disable Constraints
18
Syntax:
alter table <table> disable constraint
<constraint_name>;
Enable Constraints
19
Syntax:
alter table <table>
enable constraint <constraint_name>;
Viewing Colums Associated with
Constraints
20
Syntax:
select constraint_name, column_name
from user_cons_columns where
table_name = ‘<table>’;
21
THANK YOU