﻿{"id":261,"date":"2014-10-20T17:07:33","date_gmt":"2014-10-20T16:07:33","guid":{"rendered":"http:\/\/www.codereview.co\/?p=261"},"modified":"2014-10-15T15:06:35","modified_gmt":"2014-10-15T14:06:35","slug":"sql-interview-question-6-what-is-a-primary-key","status":"publish","type":"post","link":"http:\/\/www.codereview.co\/index.php\/sql-server-tutorials\/sql-interview-question-6-what-is-a-primary-key\/","title":{"rendered":"Sql Interview Question #7: What is a primary key?"},"content":{"rendered":"<p><strong><span style=\"color: #000000;\">Sql Interview Question\u00a0<\/span><\/strong><\/p>\n<p><span style=\"color: #000000;\"> What is a primary key?<\/span><!--more--><\/p>\n<p><span style=\"color: #000000;\"><strong>Answer<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">A PRIMARY KEY constraint is a unique identifier for a row within a database table. A primary key prevents, duplicates and ensures that all records have their own distinct values.<\/span><\/p>\n<p><span style=\"color: #000000;\">Primary keys don\u2019t allow nulls, so you are guaranteed that each record has its own unique populated value.<\/span><\/p>\n<p><span style=\"color: #000000;\">Every table should have a primary key constraint to uniquely identify each row, and only one primary key constraint can be created for each table. The primary key constraints are used to enforce entity integrity.<\/span><\/p>\n<p><span style=\"color: #000000;\">It is not possible to change the length of a column defined with a PRIMARY KEY constraint. If you need to change the length then you must first delete the existing PRIMARY KEY constraint and then re-create it with the new definition.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Thanks for reading this article,<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Next steps :<\/strong><\/span><\/p>\n<ol>\n<li><span style=\"color: #000000;\"><strong> Share this with your colleagues because Sharing is Learning<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong> Comment below if you need any assistance<\/strong><\/span><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sql Interview Question\u00a0 What is a primary key?<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[172,3],"tags":[124,46,13,12],"_links":{"self":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts\/261"}],"collection":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/comments?post=261"}],"version-history":[{"count":4,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":377,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts\/261\/revisions\/377"}],"wp:attachment":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}