Monday, December 20, 2010

oracle constraints?

Constraints are used to prevent invalid data entry into tables.
There are 5 types
1) NOT NULL
2) UNIQUE
3) PRIMARY KEY
4) FOREIGN KEY
5) CHECK

NOT NULL: Does not allow null values.That means, you can't  enter a row into the table without providing a value for the NOT NULL column.

UNIQUE: Does now allow duplicates. That means, you can't enter duplicate values into UNIQUE column but you can enter null values.

PRIMARY KEY: It works with features of  NOT NULL + UNIQUE.

FOREIGN KEY: Used to create a Parent-Child or Master-Detail relation ship between two tables. Having define foreign key on Child table, you cant enter a record into child table with out having related value in Parent Table:

CHECK: With this, one can define a range on column and we can enter values into the column only within the defined range

No comments:

Post a Comment