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

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

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

 Subscribe to Code Snippets

Adding check at the time of table creation

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

The following syntax is used to add check to the table at the time of its creation.

CREATE TABLE (col datatype, check(condition), col2 datatype,...)

More than one check constraints can be added to a single table. This will put a limitation to the values of an specific domain.

create table student(name char(20), age int check(age<=20))

The above code will add a constraint to the student table at the time of its creation to restrict the age value to 20.


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