Adding primary key in a new table

Posted by Abhisek under Sql Server category on | Views : 1673
A primary key can be created when a new table is created. To add a primary key at the time of table creation just follow the following syntax,

CREATE TABLE <table_name>(col_name datatype NOT NULL PRIMARY KEY, col_name datatype,......)

This will add a primary key to the table. We can add only one primary key to a table and a primary key don't have a NULL or duplicate value.

Comments or Responses

Login to post response