Showing posts with label constraitns. Show all posts
Showing posts with label constraitns. Show all posts

Friday, September 11, 2009

Constraints in SQL/ORACLE

Constraints

Two types of constraints are provided: column constraints and table constraints. Column constraints are associated with a single column but table constraints are associated with more than one column. Any column constraint can also be formulated as a table constraint.

The specification of a (simple) constraint has the following form:

[constraint ] primary key | unique | not null

A constraint can be named. The most important constraints are not null, unique, primary key constraints.The primary key constraint enables a unique identification of each tuple in a table.

With a primary key, the database system ensures that no duplicates appear in a table.

For example, for our EMP table, the specification

create table EMP

(

emp_code number(4) constraint pk emp primary key,

. . .

);

In this case emp_code must be unique in this table.a table must have onlyone primary key, but more than one unique keys. Null values are not allowed for primary keys.

Ads

Your Ad Here