

{"id":25064,"date":"2018-08-16T04:00:59","date_gmt":"2018-08-16T04:00:59","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=25064"},"modified":"2021-03-11T20:43:57","modified_gmt":"2021-03-11T15:13:57","slug":"default-check-constraint-in-sql","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/","title":{"rendered":"Check Constraint in SQL | Default Constraint in SQL"},"content":{"rendered":"<p>In this tutorial, we will learn about what are constraints and why do we need them for our databases.<\/p>\n<p>When we try to understand more about the constraints we see that they are just small inhibitors that help us maintain our database.<\/p>\n<p>With the various constraints, we can maintain the data in our database. In this tutorial, we will try to understand all the use cases of the constraints and then the syntax and the examples of each of them.<\/p>\n<p>Two of the popular constraints being Check and Default. Let us now dive deep into the world of constraints.<\/p>\n<h3>What are Constraints in SQL?<\/h3>\n<p>Constraints are the rules and qualifying standards we apply on our database columns. They help us to maintain the integrity of our data and help us to scan the data at the time we insert it in our records.<\/p>\n<p>In SQL, we have two important constraints:<\/p>\n<ul>\n<li>Check Constraint<\/li>\n<li>Default Constraint<\/li>\n<\/ul>\n<p>These both need to be applied when we create the table and are explicitly written with the CREATE query. Let us now understand each of these in detail.<\/p>\n<h3>What is Check Constraint in SQL?<\/h3>\n<p>Check constraint is explicitly put by the user while creating the table or is introduced when the table is being altered.<\/p>\n<p>It can be applied to one single attribute or can be applied to the whole table. It helps us ensure that the value we are inserting in our database satisfies the required condition.<\/p>\n<p><strong>Syntax to create a Check Constraint:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CREATE TABLE tableName (\r\ncol1 datatype,\r\ncol2  datatype,\r\ncol3 datatype CHECK(expression),\r\n\u2026\u2026..\r\n);\r\n<\/pre>\n<h3>What is a Default Constraint in SQL?<\/h3>\n<p>The default constraint is used to set the value of the attributes in case no value is passed while insertion is taking place in the database.<\/p>\n<p>This ensures that ambiguity does not arise in the stored data and the stored data remains meaningful. By the use of default constraints, we save the costs of cleaning and processing data before analysis.<\/p>\n<p><strong>Syntax of Default Constraint Creation:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CREATE TABLE Persons (\r\ncol1 datatype,\r\ncol2 datatype DEFAULT value,\r\ncol3 datatype,\r\n\u2026...\r\n);\r\n<\/pre>\n<h3>Uses of Constraints<\/h3>\n<p>Some of the uses of constraints in SQL are as follows:<\/p>\n<ul>\n<li>Helps to maintain data integrity and usability.<\/li>\n<li>Prevents ambiguities that would have arisen otherwise.<\/li>\n<li>Makes the data stored more informative and easy for analysis.<\/li>\n<li>Makes it easier to draw insights from the data.<\/li>\n<\/ul>\n<h3>Steps for a Default Constraint<\/h3>\n<p>We have two major steps when we talk about the default constraint:<\/p>\n<h4>1. Creation of Default Constraint with Create Query or the Alter Query<\/h4>\n<ul>\n<li><strong>Using the Create Query<\/strong><\/li>\n<\/ul>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CREATE TABLE Persons (\r\ncol1 datatype,\r\ncol2 datatype DEFAULT value,\r\ncol3 datatype,\r\n\u2026...\r\n);\r\n<\/pre>\n<p><strong>Example:<\/strong> Let us create a new table called DataFlair_employees with a default constraint on age column.<br \/>\n<strong>Query:<\/strong><\/p>\n<p><strong>a. Create the table with the Default constraint.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CREATE TABLE DataFlair_employees (\r\nName varchar(50),\r\nAge int,\r\nExperience int DEFAULT 0 );\r\n<\/pre>\n<p><strong>b. Insert Data into the table<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">INSERT INTO DataFlair_employees VALUES\r\n('Riya',24,3),\r\n('Ram',28,5),\r\n('Akash',21,1);\r\nINSERT INTO  DataFlair_employees(Name,Age) VALUES\r\n('Amit',18),\r\n('Aman',30);\r\n<\/pre>\n<p><strong>c. View the table<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Select * From DataFlair_employees;\r\n<\/pre>\n<p><strong>Output<\/strong>:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87001\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create.png\" alt=\"default create in SQL\" width=\"1920\" height=\"1032\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-1024x550.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-150x81.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-768x413.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-1536x826.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-720x387.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-520x280.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-create-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Using the Alter Query<\/strong><\/li>\n<\/ul>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE tableName\r\nALTER col2 SET DEFAULT newValue;\r\n<\/pre>\n<p><strong>Example:<\/strong> Let us now change our default value of the experience of the employee to 1 and insert a record and view the results.<br \/>\n<strong>Query:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE DataFlair_employees \r\nALTER Experience SET DEFAULT 1;\r\nINSERT INTO DataFlair_employees(Name,Age) VALUES\r\n('Raj',23);\r\nSelect * From DataFlair_employees;\r\n\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-87000\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter.png\" alt=\"default alter in SQL\" width=\"1920\" height=\"1032\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-1024x550.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-150x81.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-768x413.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-1536x826.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-720x387.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-520x280.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-alter-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h4>2. Drop the Default Constraint<\/h4>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE tableName\r\nALTER colName DROP DEFAULT;\r\n<\/pre>\n<p><strong>Example:<\/strong> Let us now see how we can Drop a Default constraint applied to our column.<br \/>\n<strong>Query:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE DataFlair_employees \r\nALTER Experience DROP DEFAULT;\r\nINSERT INTO DataFlair_employees(Name, Experience) VALUES\r\n('Rajni',28);\r\nSelect * From DataFlair_employees;\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-86999\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop.png\" alt=\"Default Drop in SQL\" width=\"1920\" height=\"1028\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-1024x548.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-768x411.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-1536x822.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-520x278.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/default-drop-320x171.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h3>Steps for a Check Constraint<\/h3>\n<p>The steps we need to follow for creating and disposing of, a Check constraint are as follows:<\/p>\n<h4>1. Create a table with Check Constraint<\/h4>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CREATE TABLE tableName (\r\ncolName1 datatype,\r\ncolName2 datatype CHECK(expression),\r\ncolName3 datatype,\r\n\u2026\u2026.\r\n);\r\n<\/pre>\n<p><strong>Example:<\/strong> Let us now create a new table DataFlair_employees with a Check on the age of employees and try to insert data into it.<\/p>\n<p><strong>Query:<\/strong><\/p>\n<ul>\n<li><strong>Create the table with Check constraint.<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">CREATE TABLE DataFlair_employees  (\r\nName varchar(50),\r\nAge int CHECK(Age&gt;=18),\r\nExperience int );\r\n<\/pre>\n<ul>\n<li><strong>Insert data into the table.<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">INSERT INTO DataFlair_employees VALUES\r\n('Rajni',28,5),\r\n('Shyam',25,3),\r\n('Nidhi',22,1),\r\n('John',21,0),\r\n('Anita',29,5),\r\n('Raj',17,0);\r\n<\/pre>\n<ul>\n<li><strong>View the table.<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Select * From DataFlair_employees;\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-86996\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation.png\" alt=\"SQL QUery\" width=\"1920\" height=\"1032\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-1024x550.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-150x81.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-768x413.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-1536x826.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-720x387.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-520x280.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-creation-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h4>2. Alter the Check Constraint<\/h4>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE tableName\r\nADD CHECK (expression);\r\n<\/pre>\n<p><strong>Example:<\/strong> Let us now make the minimum age to be 21 to join DataFlair.<br \/>\n<strong>Query:<\/strong><\/p>\n<ul>\n<li><strong>Alter the Check constraint of our database.<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE DataFlair_employees\r\nADD CHECK (Age&gt;=21);\r\n<\/pre>\n<ul>\n<li><strong>Insert data into the table.<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">INSERT INTO DataFlair_employees VALUES\r\n('Niya',21,0),\r\n('Rishi',20,0);\r\n<\/pre>\n<ul>\n<li><strong>View the table.<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Select * From DataFlair_employees;\r\n\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-86997\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter.png\" alt=\"ALter in SQL\" width=\"1920\" height=\"1028\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-1024x548.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-768x411.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-1536x822.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-720x386.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-520x278.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-alter-320x171.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h4>3. Drop the Check Constraint<\/h4>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE tableName\r\nDROP CONSTRAINT constraintName;\r\n<\/pre>\n<p><strong>Example:<\/strong> Let us now drop the constraint on our Age column.<br \/>\n<strong>Query:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ALTER TABLE DataFlair_employees\r\nDROP CONSTRAINT Age;\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-86998\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop.png\" alt=\"Drop in SQL\" width=\"1920\" height=\"1032\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-1024x550.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-150x81.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-768x413.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-1536x826.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-720x387.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-520x280.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/check-drop-320x172.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>In this tutorial, we have seen all about constraints and their uses in a database.<\/p>\n<p>Further, we have understood in detail about Check and Default constraint in detail.<\/p>\n<p>We have started right from the definition and the syntax and then the uses and moving on we have seen steps of each enclosed with required examples.<\/p>\n<p>With the help of constraints, we can keep a check on our data and maintain the data in our database so that it remains usable for a long time. For more information head over to the Constraints tutorial.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will learn about what are constraints and why do we need them for our databases. When we try to understand more about the constraints we see that they are just&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":86995,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[248,430,2486,2924,3707,3716,12766,13401,13418,13451,13540,13547],"class_list":["post-25064","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-add-constraint-sql-server","tag-alter-constraint-sql-server","tag-check-constraint-in-sql","tag-constraints-in-sql","tag-default-constraint-in-sql","tag-default-sql-server","tag-set-default-value-in-sql","tag-sql-add-constraint","tag-sql-constraint","tag-sql-drop-constraint","tag-sql-server-constraint","tag-sql-server-default-constraint"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Check Constraint in SQL | Default Constraint in SQL - DataFlair<\/title>\n<meta name=\"description\" content=\"SQL Constraint, check constraint in sql, Default Constraint in SQL, sql server add default constraint, drop constraint sql server,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Check Constraint in SQL | Default Constraint in SQL - DataFlair\" \/>\n<meta property=\"og:description\" content=\"SQL Constraint, check constraint in sql, Default Constraint in SQL, sql server add default constraint, drop constraint sql server,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-16T04:00:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-11T15:13:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Check-Constraint-and-Default-Constraint.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Check Constraint in SQL | Default Constraint in SQL - DataFlair","description":"SQL Constraint, check constraint in sql, Default Constraint in SQL, sql server add default constraint, drop constraint sql server,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/","og_locale":"en_US","og_type":"article","og_title":"Check Constraint in SQL | Default Constraint in SQL - DataFlair","og_description":"SQL Constraint, check constraint in sql, Default Constraint in SQL, sql server add default constraint, drop constraint sql server,","og_url":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-08-16T04:00:59+00:00","article_modified_time":"2021-03-11T15:13:57+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Check-Constraint-and-Default-Constraint.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"Check Constraint in SQL | Default Constraint in SQL","datePublished":"2018-08-16T04:00:59+00:00","dateModified":"2021-03-11T15:13:57+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/"},"wordCount":718,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Check-Constraint-and-Default-Constraint.jpg","keywords":["add constraint sql server","alter constraint sql server","check constraint in SQL","Constraints in SQL","default constraint in SQL","default sql server","set default value in sql","SQL add constraint","SQL Constraint","SQL drop constraint","SQL Server Constraint","sql server default constraint"],"articleSection":["SQL Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/","url":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/","name":"Check Constraint in SQL | Default Constraint in SQL - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Check-Constraint-and-Default-Constraint.jpg","datePublished":"2018-08-16T04:00:59+00:00","dateModified":"2021-03-11T15:13:57+00:00","description":"SQL Constraint, check constraint in sql, Default Constraint in SQL, sql server add default constraint, drop constraint sql server,","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Check-Constraint-and-Default-Constraint.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/08\/Check-Constraint-and-Default-Constraint.jpg","width":1200,"height":628,"caption":"Check Constraint and Default Constraint in SQL"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/default-check-constraint-in-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Searching for Groups of Scala Regex","item":"https:\/\/data-flair.training\/blogs\/tag\/searching-for-groups-of-scala-regex\/"},{"@type":"ListItem","position":3,"name":"Check Constraint in SQL | Default Constraint in SQL"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/25064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=25064"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/25064\/revisions"}],"predecessor-version":[{"id":87002,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/25064\/revisions\/87002"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/86995"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=25064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=25064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=25064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}