.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Adding primary key in a new table

Posted By:Abhisek Panda       Posted Date: November 30, 2009    Points: 10    Category: SQL Query    URL: http://www.dotnetspark.com  

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 (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.


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend