{"id":1118,"date":"2007-12-05T00:51:00","date_gmt":"2007-12-05T00:51:00","guid":{"rendered":"\/blogs\/paul\/post\/Search-Engine-QA-9-How-to-update-constraints.aspx"},"modified":"2017-04-13T09:52:05","modified_gmt":"2017-04-13T16:52:05","slug":"search-engine-qa-9-how-to-update-constraints","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/","title":{"rendered":"Search Engine Q&#038;A #9: How to update constraints?"},"content":{"rendered":"<p><font face=\"Verdana\"><font size=\"2\"><\/p>\n<p>\nA quickie today to get back into the swing of things.\n<\/p>\n<p>\nIn Kimberly&#39;s <a href=\"https:\/\/msdn.microsoft.com\/Areas\/Epx\/Content\/500.htm?aspxerrorpath=\/en-us\/library\/ms345146.aspx\">whitepaper on partitioning<\/a> she discusses the &#39;sliding window&#39; scenario (where you switch in and out partitions of data into an existing table &#8211; see <a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/indexes-from-every-angle-what-indexes-are-necessary-when-using-switch-partition\/\">this<\/a> previous post for a few more details). She recommends that the constraints are extended rather than dropped and recreated &#8211; which I totally agree with. I had a question about why this is a best practice, and is it more efficient than dropping and recreating the constraints?\n<\/p>\n<p>\nLet&#39;s create a little example to illustrate all these points. A simple table called Sales with a couple of indexes and 100000 rows of data.\n<\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\"><p>\n\t<font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\">CREATE<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">TABLE<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#000000\">salesID <\/font><font size=\"2\" color=\"#0000ff\">INT<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">IDENTITY<\/font><font size=\"2\" color=\"#808080\">,<\/font><font size=\"2\" color=\"#000000\"> SalesDate <\/font><font size=\"2\" color=\"#0000ff\">DATETIME<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">);<br \/>\n\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t<\/p>\n<p>\t<\/font><font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\">CREATE<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">CLUSTERED<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">INDEX<\/font><font size=\"2\" color=\"#000000\"> Sales_CL <\/font><font size=\"2\" color=\"#0000ff\">ON<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#000000\">SalesID<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">);<br \/>\n\t<\/font><font size=\"2\" color=\"#0000ff\">CREATE<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">NONCLUSTERED<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">INDEX<\/font><font size=\"2\" color=\"#000000\"> Sales_NCL <\/font><font size=\"2\" color=\"#0000ff\">ON<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#000000\">SalesDate<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">);<br \/>\n\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t<\/p>\n<p>\t<\/font><font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\">SET<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">NOCOUNT<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">ON<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">;<br \/>\n\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t<\/p>\n<p>\t<\/font><font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\">DECLARE<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> @a <\/font><font size=\"2\" color=\"#0000ff\">INT<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">;<br \/>\n\t<\/font><font size=\"2\" color=\"#0000ff\">SELECT<\/font><font size=\"2\" color=\"#000000\"> @a <\/font><font size=\"2\" color=\"#808080\">=<\/font><font size=\"2\" color=\"#000000\"> 1<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">;<br \/>\n\t<\/font><font size=\"2\" color=\"#0000ff\">WHILE<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#000000\">@a <\/font><font size=\"2\" color=\"#808080\">&lt;<\/font><font size=\"2\" color=\"#000000\"> 100000<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">)<br \/>\n\t<\/font><font size=\"2\" color=\"#0000ff\">BEGIN<\/font><\/font>\n\t<\/p>\n<p>\t<\/font><font size=\"2\"><\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\">\n<p>\n\t\t<font face=\"Courier New\"><font size=\"2\" color=\"#0000ff\">INSERT<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#0000ff\">INTO<\/font><font size=\"2\"> Sales <\/font><font size=\"2\" color=\"#0000ff\">VALUES<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#ff00ff\">GETDATE<\/font><font size=\"2\"> <\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">());<br \/>\n\t\t<\/font><font size=\"2\" color=\"#0000ff\">SELECT<\/font><font size=\"2\"> @a <\/font><font size=\"2\" color=\"#808080\">=<\/font><font size=\"2\"> @a <\/font><font size=\"2\" color=\"#808080\">+<\/font><font size=\"2\"> 1<\/font><font size=\"2\" color=\"#808080\">;<\/font><\/font>\n\t\t<\/p>\n<\/blockquote>\n<p>\t<\/font><font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\">END<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">;<br \/>\n\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t<\/p>\n<p>\t<\/font>\n<\/p><\/blockquote>\n<p dir=\"ltr\">\n<font size=\"2\">Now I want to create two constraints &#8211; for the lower and upper bounds of the sales date. I could do this using a single constraint with both conditions or two constraints with a single condition each. For simplicity I&#39;ll use one constraint, but first I want to see how expensive the operation is, so I&#39;m going to turn on <font face=\"Courier New\">STATISTICS IO<\/font> &#8211; this is a very cool feature that gives the IO costs of a query after it&#39;s completed.<\/font>\n<\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\"><p>\n\t<font size=\"2\"><font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\">SET<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">STATISTICS<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">IO<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">ON<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">;<br \/>\n\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t<\/p>\n<p>\t<\/font><font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t<font face=\"Courier New\">ALTER<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">TABLE<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#0000ff\">WITH<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">CHECK <\/font><font size=\"2\" color=\"#0000ff\">ADD<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#0000ff\">CONSTRAINT<\/font><font size=\"2\"> [CK_Sales_SalesDate] <\/font><font size=\"2\" color=\"#0000ff\">CHECK<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#ff00ff\">YEAR<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\">SalesDate<\/font><font size=\"2\" color=\"#808080\">)<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">&gt;=<\/font><font size=\"2\"> 2005 <\/font><font size=\"2\" color=\"#808080\">AND<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#ff00ff\">YEAR<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\">SalesDate<\/font><font size=\"2\" color=\"#808080\">)<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">&lt;<\/font><font size=\"2\"> 2008<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">);<br \/>\n\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t<\/p>\n<p>\t<\/font><\/p>\n<p dir=\"ltr\">\n\t<font size=\"2\"><font face=\"Courier New\">Table &#39;Sales&#39;. Scan count 1, logical reads 399, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<\/font><\/font>\n\t<\/p>\n<p dir=\"ltr\">\n\t<font size=\"2\">The 399 logical reads are for the table scan that&#39;s done to ensure that the constraint is valid for the data currently in the table.<\/font>\n\t<\/p>\n<p>\t<\/font>\n<\/p><\/blockquote>\n<p dir=\"ltr\">\n<font size=\"2\">So &#8211; the first question is why not drop\/create the constraint to update it? Well, what if invalid data is entered into the table between dropping and recreating the constraint?<\/font>\n<\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\"><p>\n\t<font size=\"2\"><font size=\"2\" color=\"#0000ff\"><font face=\"Courier New\">ALTER<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">TABLE<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#0000ff\">DROP<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">CONSTRAINT<\/font><font size=\"2\" color=\"#000000\"> [CK_Sales_SalesDate]<\/font><\/font><font face=\"Courier New\" size=\"2\" color=\"#808080\">;<br \/>\n\t<\/font><font size=\"2\"><font face=\"Courier New\">GO<\/font><\/font><\/font><font size=\"2\"><font size=\"2\" color=\"#0000ff\"> <\/p>\n<p>\n\t<font face=\"Courier New\">ALTER<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">TABLE<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#0000ff\">WITH<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">CHECK <\/font><font size=\"2\" color=\"#0000ff\">ADD<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#0000ff\">CONSTRAINT<\/font><font size=\"2\"> [CK_Sales_SalesDate] <\/font><font size=\"2\" color=\"#0000ff\">CHECK<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#ff00ff\">YEAR<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\">SalesDate<\/font><font size=\"2\" color=\"#808080\">)<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">&gt;=<\/font><font size=\"2\"> 2005 <\/font><font size=\"2\" color=\"#808080\">AND<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#ff00ff\">YEAR<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\">SalesDate<\/font><font size=\"2\" color=\"#808080\">)<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">&lt;<\/font><font size=\"2\"> 2009<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">);<br \/>\n\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t<\/p>\n<p>\t<\/font><font size=\"2\"><font size=\"2\"><\/p>\n<p>\n\t<font face=\"Courier New\" color=\"#ff0000\">Msg 547, Level 16, State 0, Line 1<\/font>\n\t<\/p>\n<p>\n\t<font face=\"Courier New\" color=\"#ff0000\">The ALTER TABLE statement conflicted with the CHECK constraint &quot;CK_Sales_SalesDate&quot;. The conflict occurred in database &quot;ConstraintTest&quot;, table &quot;dbo.Sales&quot;, column &#39;SalesDate&#39;.<\/font>\n\t<\/p>\n<p dir=\"ltr\">\n\t<font color=\"#000000\">The constraint can&#39;t be recreated and you have to find the invalid data and get rid of it &#8211; which may not be as easy as it sounds depending on your schema and business logic. So, the best practice is always to update a constraint. Well, you can&#39;t update an existing constraint but you can create a new constraint with different conditions and then drop the old constraint:<\/font>\n\t<\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px\"><p>\n\t\t<font size=\"2\" color=\"#0000ff\"><\/p>\n<p>\n\t\t<font face=\"Courier New\">ALTER<\/font><font face=\"Courier New\"><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">TABLE<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#0000ff\">WITH<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">CHECK <\/font><font size=\"2\" color=\"#0000ff\">ADD<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#0000ff\">CONSTRAINT<\/font><font size=\"2\"> [CK_Sales_SalesDate2] <\/font><font size=\"2\" color=\"#0000ff\">CHECK<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\" color=\"#ff00ff\">YEAR<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\">SalesDate<\/font><font size=\"2\" color=\"#808080\">)<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">&gt;=<\/font><font size=\"2\"> 2005 <\/font><font size=\"2\" color=\"#808080\">AND<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#ff00ff\">YEAR<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">(<\/font><font size=\"2\">SalesDate<\/font><font size=\"2\" color=\"#808080\">)<\/font><font size=\"2\"> <\/font><font size=\"2\" color=\"#808080\">&lt;<\/font><font size=\"2\"> 2009<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">);<br \/>\n\t\t<\/font><font size=\"2\" color=\"#0000ff\">ALTER<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">TABLE<\/font><font size=\"2\" color=\"#000000\"> Sales <\/font><font size=\"2\" color=\"#0000ff\">DROP<\/font><font size=\"2\" color=\"#000000\"> <\/font><font size=\"2\" color=\"#0000ff\">CONSTRAINT<\/font><font size=\"2\" color=\"#000000\"> [CK_Sales_SalesDate]<\/font><\/font><font face=\"Courier New\"><font size=\"2\" color=\"#808080\">;<br \/>\n\t\t<\/font><font size=\"2\">GO<\/font><\/font>\n\t\t<\/p>\n<p>\t\t<\/font><\/p>\n<p dir=\"ltr\">\n\t\t<font size=\"2\"><font face=\"Courier New\">Table &#39;Sales&#39;. Scan count 1, logical reads 399, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.<\/font><\/font>\n\t\t<\/p>\n<\/blockquote>\n<p dir=\"ltr\">\n\t<font size=\"2\">The second question is which way is more efficient? The answer is neither. Dropping and recreating the constraint will obviously do a table scan again, but so does adding the new constraint &#8211; even though there&#39;s a trusted constraint in place already which guarantees that adding the new constraint can&#39;t possibly fail!!! Hopefully in the future the smarts will be built into the SQL Engine to recognize this and not do the unnecessary table scan (this process is&nbsp;known as&nbsp;<em>interval subsumption<\/em> &#8211;&nbsp;according to my&nbsp;geeky wife :-))<\/font>\n\t<\/p>\n<p>\t<\/font><\/font><\/font>\n<\/p><\/blockquote>\n<p><\/font><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A quickie today to get back into the swing of things. In Kimberly&#39;s whitepaper on partitioning she discusses the &#39;sliding window&#39; scenario (where you switch in and out partitions of data into an existing table &#8211; see this previous post for a few more details). She recommends that the constraints are extended rather than dropped [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,65,78],"tags":[],"class_list":["post-1118","post","type-post","status-publish","format-standard","hentry","category-constraints","category-partitioning","category-search-engine-q-and-a"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Search Engine Q&amp;A #9: How to update constraints? - Paul S. Randal<\/title>\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.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Search Engine Q&amp;A #9: How to update constraints? - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"A quickie today to get back into the swing of things. In Kimberly&#039;s whitepaper on partitioning she discusses the &#039;sliding window&#039; scenario (where you switch in and out partitions of data into an existing table &#8211; see this previous post for a few more details). She recommends that the constraints are extended rather than dropped [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2007-12-05T00:51:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-13T16:52:05+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/\",\"name\":\"Search Engine Q&A #9: How to update constraints? - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2007-12-05T00:51:00+00:00\",\"dateModified\":\"2017-04-13T16:52:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Search Engine Q&#038;A #9: How to update constraints?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Search Engine Q&A #9: How to update constraints? - Paul S. Randal","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.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/","og_locale":"en_US","og_type":"article","og_title":"Search Engine Q&A #9: How to update constraints? - Paul S. Randal","og_description":"A quickie today to get back into the swing of things. In Kimberly&#39;s whitepaper on partitioning she discusses the &#39;sliding window&#39; scenario (where you switch in and out partitions of data into an existing table &#8211; see this previous post for a few more details). She recommends that the constraints are extended rather than dropped [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/","og_site_name":"Paul S. Randal","article_published_time":"2007-12-05T00:51:00+00:00","article_modified_time":"2017-04-13T16:52:05+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/","name":"Search Engine Q&A #9: How to update constraints? - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2007-12-05T00:51:00+00:00","dateModified":"2017-04-13T16:52:05+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-9-how-to-update-constraints\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Search Engine Q&#038;A #9: How to update constraints?"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=1118"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1118\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=1118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=1118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=1118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}