{"id":2957,"date":"2013-12-16T05:34:23","date_gmt":"2013-12-16T05:34:23","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=2957"},"modified":"2013-12-16T05:35:00","modified_gmt":"2013-12-16T05:35:00","slug":"%e5%a2%9e%e5%8a%a0%e6%96%b0%e5%88%97%e8%b5%8b%e5%80%bc%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2013\/12\/16\/%e5%a2%9e%e5%8a%a0%e6%96%b0%e5%88%97%e8%b5%8b%e5%80%bc%e9%97%ae%e9%a2%98\/","title":{"rendered":"\u589e\u52a0\u65b0\u5217\u8d4b\u503c\u95ee\u9898"},"content":{"rendered":"<p>\u6307\u5b9a\u4e86\u9ed8\u8ba4\u503c<br \/>\n\u82e5\u589e\u52a0\u4e86 not null\u9650\u5236\uff0c\u5219\u81ea\u52a8\u5c06\u6240\u6709\u7684\u65b0\u5217\u503c\u8d4b\u4e88\u9ed8\u8ba4\u503c\u3002<br \/>\n\u6216\u8005\u4e0d\u52a0 not null\u9650\u5236\uff0c\u4f46\u6307\u5b9a with values\u4fee\u9970\uff0c\u4e5f\u4f1a\u81ea\u52a8\u5c06\u6240\u6709\u7684\u65b0\u5217\u503c\u8d4b\u4e88\u9ed8\u8ba4\u503c\u3002<br \/>\n\u53ea\u6709\u6307\u5b9a\u4e86\u9ed8\u8ba4\u503c\uff0c\u65e2\u6ca1\u6709not null,\u6709\u6ca1\u6709with values\u65f6\uff0c\u624d\u53ea\u5c06\u65b0insert\u7684\u5217\u8d4b\u503c\u3002<br \/>\n\u53c2\u8003\uff1a<a href=\"http:\/\/technet.microsoft.com\/zh-cn\/library\/ms187742.aspx\">column_definition<\/a><\/p>\n<pre class=\"brush:sql;first-line:1;pad-line-numbers:true;highlight:null;collapse:false;\">\r\nUSE tempdb;\r\nGO\r\n--Safety Check\r\nIF OBJECT_ID(&#39;dbo.test&#39;,&#39;U&#39;) IS NOT NULL\r\n    DROP TABLE dbo.test;\r\nGO\r\n\r\n--Create the test table\r\nCREATE TABLE dbo.test ( Col1 INT );\r\nGO\r\n\r\n--Insert some test data\r\nINSERT INTO dbo.test ( Col1 ) \r\nSELECT 1 UNION ALL\r\nSELECT 2 UNION ALL\r\nSELECT 3 UNION ALL\r\nSELECT 4 UNION ALL\r\nSELECT 5;\r\nGO\r\n\r\n--Add a new, NOT NULL column with default constraint\r\n--Use with WITH VALUES clause to also populate the columns\r\nALTER TABLE dbo.test \r\n    ADD col2 INT NOT NULL DEFAULT(0),\r\n    col3 INT  DEFAULT(0) WITH VALUES,\r\n    col4 INT DEFAULT(0)\r\n    ;\r\nGO\r\n\r\nSELECT *\r\nFROM test\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6307\u5b9a\u4e86\u9ed8\u8ba4\u503c \u82e5\u589e\u52a0\u4e86 not null\u9650\u5236\uff0c\u5219\u81ea\u52a8\u5c06\u6240\u6709\u7684\u65b0\u5217\u503c\u8d4b\u4e88\u9ed8\u8ba4\u503c\u3002 \u6216\u8005\u4e0d\u52a0 not null\u9650\u5236 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2957","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/2957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=2957"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/2957\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=2957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=2957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=2957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}