Docstoc

Constraints

Document Sample
Constraints Powered By Docstoc
					Constraints

1

Constraint Clause
• An integrity constraint is a rule that restricts the values for one or more columns in a table or an index-only table.

• It can appear in either CREATE or ALTER TABLE commands. • Identifies the integrity constraint by the name constraint. It is stored in the data dictionary along with the definition of the integrity constraint. (If omit this identifier, Oracle generates a name with this form: SYS_Cn).
2

• NULL : Specifies that a column can contain NULL values (Default). • NOT NULL : Specifies that a column can contain NULL values. • UNIQUE KEY : Designates a column or combination of columns as a unique key. Cannot define UNIQUE constraints on index-only tables. • PRIMARY KEY : Designates a column or combination of columns as the table's primary key. • FOREIGN KEY : Designates a column or combination of columns as the foreign key in a referential integrity constraint.
3

• REFERENCES : Identifies the primary or unique key that is referenced by a foreign key in a referential integrity constraint.

• ON DELETE CASCADE :Specifies that Oracle maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed. • CHECK : Specifies a condition that each row in the table must satisfy.
4

• DEFERRABLE* : Indicates that constraint checking can be deferred until the end of the transaction by using the SET CONSTRAINT(S) command.

• NOT DEFERRABLE (Default)* : Indicates that this constraint is checked at the end of each DML statement. A constraint's deferrability status cannot be altered; Must drop the constraint and recreate it.

5

DEFERRABLE*

• INITIALLY IMMEDIATE (Default) : Indicates that at the start of every transaction, the default is to check this constraint at the end of every DML statement. • INITIALLY DEFERRED : Implies that this constraint is DEFERRABLE and specifies that, by default, the constraint is checked only at the end of each transaction.

6

• DISABLE : Disables the integrity constraint. If an integrity constraint is disabled, Oracle does not enable it. If specified, Oracle automatically enables the integrity constraint.

7


				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:19
posted:8/29/2009
language:English
pages:7