Saturday, 19 November 2011


The PRIMARY KEY is one or more column(s) in a table used to uniquely identify each row in the table.
The PRIMARY KEY in a table has special attributes:
  • The NOT NULL attribute is automatic active.
  • The Data held across the column must be unique.
  • Defines column as a mandatory column.

Simple key: A single column primary key is known as simple key.
Composite key: A multicolumn primary key is called a composite primary key.

PRIMARY KEY constraint defined at the Column level

Syntax:
CREATE TABLE Table_Name
(
Column_Name1 Datatype (size) PRIMARY KEY
Column_Name2 Datatype (size) PRIMARY KEY
....
);
Example Statement:
CREATE TABLE Student_Detail
(
S_No number(2) PRIMARY KEY,
Name varchar(25),
Total number(3),
);

PRIMARY KEY constraint defined at the Table level

Syntax:
CREATE TABLE Table_Name
(
Column_Name1 Datatype(size),
Column_Name2 DataType(Size),
......
PRIMARY KEY (Column_Name,Column_Name,..)
);
Example Statement:
CREATE TABLE Student_Detail
(
S_No number(2),
Name varchar(25),
Total number(3),
PRIMARY KEY (S_No,Total)
);

0 comments:

Post a Comment

TrainingHUB. Powered by Blogger.

Total Pageviews

THE BEST QTP TRAINING INSTITUTE IN HYDERABAD

QTP Training in hyderabad

Sql Tutorial

Popular Posts

Our Facebook Page

TrainingHUB

Followers