Please send your Questions & Answers or Feedback to "mohan@javabook.org"

What is Primary Key constraints ?

The Primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself , or it can be an artificial field.

A primary key can consist of one or more fields on a table.

When multiple fields are used as a primary key, they are called a composite key.

Syntax:

 

column name datatype [CONSTRAINT constraint_name] PRIMARY KEY

 

Example:

 

CREATE TABLE Persons

(

 Person_Id int NOT NULL PRIMARY KEY,

 LastName varchar(255) NOT NULL,

 FirstName varchar(255),

 Address varchar(255),

 City varchar(255)

);

Related Posts Plugin for WordPress, Blogger...
Flag Counter