<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4860,"date":"2022-09-27T06:00:52","date_gmt":"2022-09-27T06:00:52","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4860"},"modified":"2022-09-27T06:01:46","modified_gmt":"2022-09-27T06:01:46","slug":"what-is-default-constraint-in-sql","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/","title":{"rendered":"What is Default constraint in SQL ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table.<\/li>\n<li style=\"text-align: justify;\">The default constraint is used to define a default value for a column so that the default value will be added to all new records if no other value is specified.<\/li>\n<li style=\"text-align: justify;\">For example, if we set the default value to 85000 as a default constraint for the E_salary column, then all the other entries in the column will have a default constraint value of 85000 until no other values have been assigned for default constraint during insertion.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4862 aligncenter\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png\" alt=\"\" width=\"1030\" height=\"374\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png 1030w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql-300x109.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql-1024x372.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql-768x279.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql-390x142.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql-820x298.png 820w\" sizes=\"(max-width: 1030px) 100vw, 1030px\" \/><\/p>\n<p style=\"text-align: justify;\">Syntax for setting a default constraint. Start by\u00a0 creating a new table and adding a default constraint to one of its columns.<\/p>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-sql code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-sql code-embed-code\">create table stu1(s_id int, s_name varchar(20), s_marks int default 50)<\/code><\/pre> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table. The default constraint is used to define a default value for a column so that the default value will be added to all new records if no other value is specified. For [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[6547],"tags":[18619,18618,18623,18624,18621,18620,18616,18622,18614,18625,18613,18615,18617],"class_list":["post-4860","post","type-post","status-publish","format-standard","hentry","category-sql","tag-add-default-constraint-in-sql","tag-check-constraint-in-sql","tag-default-constraint-in-mysql","tag-default-constraint-in-oracle","tag-default-in-sql","tag-drop-default-constraint-in-sql","tag-how-to-use-default-in-sql","tag-index-constraint-in-sql","tag-mysql-default-constraint","tag-set-default-value-in-sql-select-query","tag-sql-default-constraint","tag-sql-default-constraint-with-examples","tag-what-is-default-constraint-in-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Default constraint in SQL ? - SQL Default Constraint<\/title>\n<meta name=\"description\" content=\"What is Default constraint in SQL ? - Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Default constraint in SQL ? - SQL Default Constraint\" \/>\n<meta property=\"og:description\" content=\"What is Default constraint in SQL ? - Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-27T06:00:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-27T06:01:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/\",\"name\":\"What is Default constraint in SQL ? - SQL Default Constraint\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png\",\"datePublished\":\"2022-09-27T06:00:52+00:00\",\"dateModified\":\"2022-09-27T06:01:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is Default constraint in SQL ? - Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png\",\"width\":1030,\"height\":374},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Default constraint in SQL ? - SQL Default Constraint","description":"What is Default constraint in SQL ? - Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table.","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:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/","og_locale":"en_US","og_type":"article","og_title":"What is Default constraint in SQL ? - SQL Default Constraint","og_description":"What is Default constraint in SQL ? - Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/","og_site_name":"Wikitechy","article_published_time":"2022-09-27T06:00:52+00:00","article_modified_time":"2022-09-27T06:01:46+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/","name":"What is Default constraint in SQL ? - SQL Default Constraint","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png","datePublished":"2022-09-27T06:00:52+00:00","dateModified":"2022-09-27T06:01:46+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is Default constraint in SQL ? - Constraints are a certain set of rules used for processing data and limiting the type of data that can go into the table.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/sql\/what-is-default-constraint-in-sql\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/09\/default-constraint-sql.png","width":1030,"height":374},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4860","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4860"}],"version-history":[{"count":1,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4860\/revisions"}],"predecessor-version":[{"id":4863,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4860\/revisions\/4863"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}