{"id":30,"date":"2007-12-30T18:41:29","date_gmt":"2007-12-30T18:41:29","guid":{"rendered":""},"modified":"2007-12-30T18:41:29","modified_gmt":"2007-12-30T18:41:29","slug":"30","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=30","title":{"rendered":"SQL\u5e94\u7528\u5f00\u53d1\u4e4b2"},"content":{"rendered":"<p>SQL Server \u6570\u636e\u5e93\u8868\u7ba1\u7406<br \/>\u7ee7\u7eed\u4e0a\u4e00\u8282<\/p>\n<p>\u8868\u76f8\u5173\u7684\u51e0\u4e2a\u6982\u5ff5\uff1a<br \/>\u6570\u636e\u5b8c\u6574\u6027\uff1a\u662f\u8981\u6c42\u6570\u636e\u5e93\u4e2d\u6570\u636e\u5177\u6709\u51c6\u786e\u6027\uff0c\u51c6\u786e\u6027\u662f\u901a\u8fc7\u6570\u636e\u5e93\u8868\u7684\u8bbe\u8ba1\u548c\u7ea6\u675f\u6765\u5b9e\u73b0\u7684\u3002<br \/>\u4e3a\u4e86\u5b9e\u73b0\u5b8c\u6574\u6027\uff0c\u6570\u636e\u5e93\u9700\u8981\u505a\u4e24\u65b9\u9762\u5de5\u4f5c\uff0c 1 \u68c0\u9a8c\u6bcf\u884c\u6570\u636e\u662f\u5426\u7b26\u5408\u8981\u6c42 2&nbsp;&nbsp; \u68c0\u6d4b\u6bcf\u5217\u6570\u636e\u662f\u5426\u7b26\u5408\u8981\u6c42<br \/>SQL Server \u63d0\u4f9b\u56db\u79cd\u7c7b\u578b\u7684\u7ea6\u675f\uff08Constraint\uff09<br \/>1 \u5b9e\u4f53\u5b8c\u6574\u6027\u7ea6\u675f<br \/>\u8981\u6c42\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u6570\u636e\u90fd\u53cd\u6620\u4e0d\u540c\u7684\u5b9e\u4f53\uff0c\u4e0d\u80fd\u5b58\u5728\u76f8\u540c\u7684\u6570\u636e\u884c\u3002<br \/>\u901a\u8fc7\u7d22\u5f15\u3001\u552f\u4e00\u7ea6\u675f\u3001\u6731\u952e\u7ea6\u675f\u3001\u6807\u8bc6\u5217\u5c5e\u6027 \u7b49\u53ef\u4ee5\u5b9e\u73b0\u8868\u7684\u5b9e\u4f53\u5b8c\u6574\u6027\u3002<br \/>2 \u57df\u5b8c\u6574\u6027\u7ea6\u675f<br \/>\u6307\u7ed9\u5b9a\u5217\u7684\u8f93\u5165\u6709\u6548\u6027\u3002<br \/>\u901a\u8fc7\u9650\u5236\u6570\u636e\u7c7b\u578b\u3001\u68c0\u67e5\u7ea6\u675f\u3001\u8f93\u5165\u683c\u5f0f\u3001\u5916\u952e\u7ea6\u675f\u3001\u9ed8\u8ba4\u503c\u3001\u975e\u7a7a\u7ea6\u675f\u7b49\u591a\u79cd\u65b9\u6cd5\u5b9e\u73b0\u8868\u7684\u57df\u5b8c\u6574\u6027\u3002<br \/>3 \u5f15\u7528\u5b8c\u6574\u6027\u7ea6\u675f<br \/>\u5728\u8f93\u5165\u6216\u5220\u9664\u6570\u636e\u884c\u65f6\uff0c\u5f15\u7528\u5b8c\u6574\u6027\u7ea6\u675f\u7528\u6765\u4fdd\u6301\u8868\u4e4b\u95f4\u5df2\u5b9a\u4e49\u7684\u5173\u7cfb\u3002<\/p>\n<p>\u5728\u5f3a\u5236\u5b8c\u6574\u6027\u65f6\uff0cSQL Server \u7981\u6b62\u7528\u6237\u8fdb\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<br \/>\u5f53\u4e3b\u8868\u4e2d\u6ca1\u6709\u5173\u8054\u7684\u8bb0\u5f55\u65f6\uff0c\u5c06\u8bb0\u5f55\u6dfb\u52a0\u5230\u76f8\u5173\u8868\u4e2d\u3002<br \/>\u66f4\u6539\u4e3b\u8868\u4e2d\u7684\u503c\u5bfc\u81f4\u76f8\u5173\u8868\u7684\u8bb0\u5f55\u5b64\u7acb\u3002<br \/>\u4ece\u4e3b\u8868\u5220\u9664\u8bb0\u5f55\uff0c\u4f46\u4ecd\u5b58\u5728\u4e0e\u8be5\u8bb0\u5f55\u5339\u914d\u7684\u76f8\u5173\u8bb0\u5f55\u3002<\/p>\n<p>\u5f15\u7528\u5b8c\u6574\u6027\u901a\u8fc7\u4e3b\u952e\u548c\u5916\u952e\u4e4b\u95f4\u7684\u5f15\u7528\u5173\u7cfb\u6765\u5b9e\u73b0\u3002<\/p>\n<p>4 \u81ea\u5b9a\u4e49\u5b8c\u6574\u6027\u7ea6\u675f<br \/>\u7528\u6237\u5b9a\u4e49\u5b8c\u6574\u6027\u7528\u6765\u5b9a\u4e49\u7279\u5b9a\u7684\u89c4\u5219\u3002<\/p>\n<p>\u4e3b\u952e\uff08Primary Key\uff09\u548c\u5916\u952e\uff08Foreign Key\uff09<br \/>\u8868\u4e2d\u6709\u4e00\u5217\u6216\u51e0\u5217\u7ec4\u5408\u7684\u503c\u7528\u6765\u552f\u4e00\u5730\u6807\u8bc6\u8868zhogn\u7684\u6bcf\u4e00\u884c\uff0c\u8fd9\u6837\u7684\u4e00\u5217\u6216\u8005\u591a\u5217\u7ec4\u5408\u53eb\u505a\u8868\u7684\u4e3b\u952e\u3002<br \/>\u4e00\u4e2a\u8868\u53ea\u80fd\u6709\u4e00\u4e2a\u4e3b\u952e\uff0c\u4e3b\u952e\u7ea6\u675f\u786e\u4fdd\u8868\u4e2d\u884c\u662f\u552f\u4e00\u7684\u3002<br \/>\u5982\u679c\u4e24\u5217\u970d\u591a\u5217\u7ec4\u5408\u8d77\u6765\u552f\u4e00\u5730\u6807\u8bc6\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\uff0c\u5219\u8be5\u4e3b\u952e\u4e5f\u53eb\u7ec4\u5408\u952e\u3002<br \/>\u9009\u62e9\u4e3b\u952e\u8981\u8003\u8651\uff0c\u6700\u5c11\u6027\u548c\u7a33\u5b9a\u6027\u7684\u539f\u5219\u3002<br \/>\u5916\u952e\u662f\u76f8\u5bf9\u4e8e\u4e3b\u952e\u800c\u8a00\uff0c\u5728\u5b50\u8868\u4e2d\u5bf9\u5e94\u4e8e\u4e3b\u952e\u7684\u5217\u5728\u5b50\u8868\u4e2d\u6210\u4e3a\u5916\u952e\u6216\u5f15\u7528\u952e\u3002\u5b83\u7684\u503c\u8981\u6c42\u4e0e\u4e3b\u8868\u7684\u4e3b\u952e\u6216\u8005\u552f\u4e00\u952e\u76f8\u5bf9\u5e94\uff0c\u5916\u952e\u7528\u6765\u5f3a\u5236\u5f15\u7528\u5b8c\u6574\u6027\u3002<\/p>\n<p>\u5728\u4f01\u4e1a\u7ba1\u7406\u5668\u4e2d\u5efa\u7acb\u6570\u636e\u5e93<br \/>\u53f3\u51fb\u6570\u636e\u5e93\u4e0b\u7684\u8868\uff0c\u9009\u62e9\u65b0\u5efa\u8868\uff0c\u5c31\u53ef\u4ee5\u8f93\u5165\u5b9a\u4e49\u8868\u7684\u4e0d\u540c\u5217\u3002<br \/>SQL Server \u4e2d\u5e38\u7528\u7684\u6570\u636e\u7c7b\u578b<br \/>\u76f8\u5173\u8054\u63a5\uff1a<br \/><a href=\"http:\/\/hi.baidu.com\/tomclub\/blog\/item\/bb84f21f98c8e0f7e1fe0b2a.html\" target=\"_blank\" rel=\"external\">http:\/\/hi.baidu.com\/tomclub\/blog\/item\/bb84f21f98c8e0f7e1fe0b2a.html<\/a><\/p>\n<p>\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a\uff1a\u6570\u636e\u5e93\u7684\u5217\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a\u65f6\u4e00\u9879\u7ea6\u675f\u3002<\/p>\n<p>\u5efa\u7acb\u4e3b\u952e\uff1a\u5728\u9700\u8981\u5efa\u7acb\u4e3a\u4e3b\u952e\u7684\u5217\u4e0a\u53f3\u51fb\u9009\u62e9\u8bbe\u7f6e\u4e3b\u952e\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\u9ed8\u8ba4\u503c\uff1a\u6709\u65f6\uff0c\u5bf9\u67d0\u9879\u6570\u636e\u8f93\u5165\u7684\u65f6\u5019\u603b\u662f\u5b58\u5728\u4e00\u4e2a\u7f3a\u7701\u7684\u503c\uff0c\u8868\u7684\u9ed8\u8ba4\u503c\u80fd\u591f\u8bbe\u5b9a\u4e00\u4e2a\u503c\uff0c\u6bcf\u5f53\u7528\u6237\u5728\u67d0\u4e00\u5217\u8f93\u5165\u6570\u636e\u7684\u65f6\u5019\u5728\u6240\u5b9a\u4e49\u7684\u503c\u63d0\u4f9b\u7ed9\u8fd9\u4e00\u5217\u3002<\/p>\n<p>\u6807\u8bc6\u5217\uff1a\u5bf9\u5217\u7684\u533a\u5206\u3002<br \/>\u5982\u679c\u4e00\u5217\u7684\u6570\u636e\u5c5e\u4e8e\u6570\u5b57\u7c7b\u578b\uff0c\u624d\u53ef\u4ee5\u628a\u8be5\u5217\u5b9a\u4e49\u4e3a\u6807\u8bc6\u5217\u3002<br \/>\u5b9a\u4e49\u6210\u6807\u8bc6\u5217\u4faf\u8fd8\u8981\u6307\u5b9a\u6807\u8bc6\u79cd\u5b50\u548c\u6807\u8bc6\u9012\u589e\u91cf\uff0c\u9ed8\u8ba4\u90fd\u4e3a1\u3002<br \/>\u5b9a\u4e49\u4e86\u6807\u8bc6\u5217\u4e4b\u540e\uff0c\u4ee5\u540e\u6bcf\u6b21\u8f93\u5165\u6570\u636e\u7684\u65f6\u5019\uff0c\u8be5\u5217\u968f\u6570\u636e\u884c\u7684\u589e\u52a0\u81ea\u52a8\u589e\u52a0\u6570\u5b57\uff0c\u5e76\u4e14\u4e0d\u91cd\u590d\u3002<\/p>\n<p>\u8868\u95f4\u5173\u7cfb\uff1a\u5efa\u7acb\u8868\u95f4\u5173\u7cfb\u5b9e\u9645\u4e0a\u5c31\u662f\u5b9e\u65bd\u5f15\u7528\u5b8c\u6574\u6027\u7ea6\u675f\uff0c\u5efa\u7acb\u4e3b\u8868\u548c\u5b50\u8868\u5173\u7cfb\u3002<br \/>\u8bbe\u8ba1\u8868\u7684\u65f6\u5019 \u5728\u5feb\u6377\u83dc\u5355\u9009\u62e9\u5173\u7cfb\u547d\u4ee4 \u5355\u51fb\u65b0\u5efa\u6309\u94ae \u9009\u62e9\u4e3b\u8868\u548c\u5916\u952e\u8868\uff0c\u9009\u62e9\u5b57\u6bb5\uff0c\u5355\u51fb\u5173\u95ed\u6309\u94ae\uff0c\u4fdd\u5b58\u8868\u7ed3\u6784\u4e4b\u540e\u4ed6\u4eec\u7684\u4e3b\u5916\u952e\u5173\u7cfb\u5c31\u5efa\u7acb\u4e86\u3002<br \/>\u8981\u67e5\u770b\u5173\u7cfb\u53ef\u4ee5\u5728\u5173\u7cfb\u56fe\u5904\u7684\u5feb\u6377\u83dc\u5355\u4e2d\u9009\u62e9\u65b0\u5efa\u6570\u636e\u5e93\u5173\u7cfb\u56fe\uff0c\u6839\u636e\u5411\u5bfc\u9009\u62e9\u9700\u8981\u663e\u793a\u5173\u7cfb\u7684\u8868\u3002<\/p>\n<p>\u5efa\u7acb\u68c0\u67e5\u7ea6\u675f\uff1a\u68c0\u67e5\u7ea6\u675f\u4e5f\u53ebCheck\u7ea6\u675f\uff0c\u7528\u4e8e\u5b9a\u4e49\u5217\u4e2d\u53ef\u4ee5\u63a5\u53d7\u7684\u6570\u636e\u503c\u6216\u8005\u683c\u5f0f\u3002\u5728\u8bbe\u8ba1\u8868\u7684\u65f6\u5019\uff0c\u901a\u8fc7\u5feb\u6377\u83dc\u5355\u9009\u62e9check\u7ea6\u675f\uff0c\u65b0\u5efa\u7ea6\u675f\uff0c\u8f93\u5165\u76f8\u5173\u7ea6\u675f\u8868\u8fbe\u5f0f\u5982\uff1a(\u5b57\u6bb5 LIKE &#8216;%@%&#8217;)&#8211;\u5bf9\u7535\u5b50\u90ae\u4ef6\u7684\u683c\u5f0f\u7ea6\u675f\u3002<\/p>\n<p>\u5bfc\u5165\u5bfc\u51fa\u6570\u636e\uff1a\u6570\u636e\u8f6c\u6362\u670d\u52a1DTS\u53ef\u4ee5\u8fdb\u884c\u5bfc\u5165\u548c\u5bfc\u51fa\u64cd\u4f5c\uff0c\u628a\u6570\u636e\u5bfc\u51fa\u4e3a\u6587\u672c\u6587\u4ef6\u6216\u8005excel\u6587\u4ef6\u7b49\u3002<br \/>\u5728\u5feb\u6377\u83dc\u5355\u4e2d\u9009\u62e9\u6240\u6709\u4efb\u52a1\uff0c\u5bfc\u51fa\u6570\u636e\uff0c\u9009\u62e9\u4ece\u4f55\u5904 \u53d6\u5f97\u6570\u636e\uff08\u9009\u62e9\u76f8\u5e94\u670d\u52a1\u5668\uff0c\u8eab\u4efd\u9a8c\u8bc1\u65b9\u5f0f\uff0c\u4ee5\u53ca\u6570\u636e\u5e93\u6587\u4ef6\u7b49\uff09\u4e0b\u4e00\u6b65\u9009\u62e9\u76ee\u7684\uff08\u5bfc\u51fa\u7684\u6570\u636e\u683c\u5f0f\u7b49\uff09\uff0c\u8f93\u5165\u6587\u4ef6\u540d\uff0c\u4e0b\u4e00\u6b65\u8bbe\u7f6e\u5bfc\u51fa\u683c\u5f0f\uff0c\u786e\u5b9a\u7acb\u5373\u8fd0\u884c\u8be5DTS\u5b8c\u6210\u8f6c\u6362\u3002<\/p>\n<p>\u5220\u9664\u8868\uff1a\u5bf9\u4e8e\u5efa\u7acb\u4e3b\u5916\u952e\u5173\u7cfb\u7684\u8868\uff0c\u5982\u679c\u8981\u5220\u9664\u4e3b\u8868\uff0c\u5219\u9996\u5148\u8981\u5220\u9664\u76f8\u5173\u5b50\u8868\uff0c\u4fdd\u8bc1\u6570\u636e\u7684\u5f15\u7528\u5b8c\u6574\u6027\uff0c\u5220\u9664\u8868\u4e00\u5b9a\u8981\u614e\u91cd\uff0c\u4e0d\u7136\u4f1a\u9020\u6210\u6709\u7528\u6570\u636e\u4e22\u5931\u3002<\/p>\n<p>&lt;\u5b8c&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server \u6570\u636e\u5e93\u8868\u7ba1\u7406\u7ee7\u7eed\u4e0a\u4e00\u8282 \u8868\u76f8\u5173\u7684\u51e0\u4e2a\u6982\u5ff5\uff1a\u6570\u636e&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-DB"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}