{"id":139065,"date":"2024-10-31T17:57:29","date_gmt":"2024-10-31T09:57:29","guid":{"rendered":"https:\/\/server.hk\/cnblog\/139065\/"},"modified":"2024-10-31T17:57:30","modified_gmt":"2024-10-31T09:57:30","slug":"sql-server%e4%bd%bf%e7%94%a8%e7%b4%a2%e5%bc%95%e5%af%a6%e7%8f%be%e6%95%b8%e6%93%9a%e8%a8%aa%e5%95%8f%e5%84%aa%e5%8c%96","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/139065\/","title":{"rendered":"SQL Server\u4f7f\u7528\u7d22\u5f15\u5be6\u73fe\u6578\u64da\u8a2a\u554f\u512a\u5316"},"content":{"rendered":"<h1 id=\"sql-server%e4%bd%bf%e7%94%a8%e7%b4%a2%e5%bc%95%e5%af%a6%e7%8f%be%e6%95%b8%e6%93%9a%e8%a8%aa%e5%95%8f%e5%84%aa%e5%8c%96-AlPwRPvwte\">SQL Server\u4f7f\u7528\u7d22\u5f15\u5be6\u73fe\u6578\u64da\u8a2a\u554f\u512a\u5316<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u5c0d\u65bc\u61c9\u7528\u7a0b\u5e8f\u7684\u6574\u9ad4\u6548\u7387\u81f3\u95dc\u91cd\u8981\u3002SQL Server\u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u5de5\u5177\u548c\u6280\u8853\u4f86\u512a\u5316\u6578\u64da\u8a2a\u554f\uff0c\u5176\u4e2d\u7d22\u5f15\u662f\u6700\u91cd\u8981\u7684\u6280\u8853\u4e4b\u4e00\u3002\u672c\u6587\u5c07\u63a2\u8a0eSQL Server\u4e2d\u7d22\u5f15\u7684\u5de5\u4f5c\u539f\u7406\u53ca\u5176\u5982\u4f55\u5e6b\u52a9\u5be6\u73fe\u6578\u64da\u8a2a\u554f\u7684\u512a\u5316\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e7%b4%a2%e5%bc%95%ef%bc%9f-AlPwRPvwte\">\u4ec0\u9ebc\u662f\u7d22\u5f15\uff1f<\/h2>\n<p>\u7d22\u5f15\u662f\u4e00\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u65e8\u5728\u63d0\u9ad8\u6578\u64da\u6aa2\u7d22\u7684\u901f\u5ea6\u3002\u5b83\u985e\u4f3c\u65bc\u66f8\u7c4d\u7684\u76ee\u9304\uff0c\u5141\u8a31\u6578\u64da\u5eab\u5feb\u901f\u5b9a\u4f4d\u6240\u9700\u7684\u6578\u64da\uff0c\u800c\u7121\u9700\u6383\u63cf\u6574\u500b\u8868\u3002SQL Server\u652f\u6301\u591a\u7a2e\u7d22\u5f15\u985e\u578b\uff0c\u5305\u62ec\u805a\u96c6\u7d22\u5f15\u3001\u975e\u805a\u96c6\u7d22\u5f15\u3001\u552f\u4e00\u7d22\u5f15\u548c\u5168\u6587\u7d22\u5f15\u7b49\u3002<\/p>\n<h2 id=\"%e7%b4%a2%e5%bc%95%e7%9a%84%e9%a1%9e%e5%9e%8b-AlPwRPvwte\">\u7d22\u5f15\u7684\u985e\u578b<\/h2>\n<ul>\n<li><strong>\u805a\u96c6\u7d22\u5f15\uff1a<\/strong>\u805a\u96c6\u7d22\u5f15\u6c7a\u5b9a\u4e86\u6578\u64da\u5728\u78c1\u789f\u4e0a\u7684\u7269\u7406\u5b58\u5132\u9806\u5e8f\u3002\u6bcf\u500b\u8868\u53ea\u80fd\u6709\u4e00\u500b\u805a\u96c6\u7d22\u5f15\uff0c\u901a\u5e38\u7528\u65bc\u4e3b\u9375\u3002<\/li>\n<li><strong>\u975e\u805a\u96c6\u7d22\u5f15\uff1a<\/strong>\u975e\u805a\u96c6\u7d22\u5f15\u662f\u6307\u6578\u64da\u7684\u908f\u8f2f\u9806\u5e8f\u8207\u7269\u7406\u5b58\u5132\u9806\u5e8f\u4e0d\u540c\u3002\u9019\u7a2e\u7d22\u5f15\u53ef\u4ee5\u6709\u591a\u500b\uff0c\u4e26\u4e14\u53ef\u4ee5\u5305\u542b\u6307\u5411\u8868\u4e2d\u6578\u64da\u7684\u6307\u91dd\u3002<\/li>\n<li><strong>\u552f\u4e00\u7d22\u5f15\uff1a<\/strong>\u552f\u4e00\u7d22\u5f15\u78ba\u4fdd\u7d22\u5f15\u5217\u4e2d\u7684\u6240\u6709\u503c\u90fd\u662f\u552f\u4e00\u7684\uff0c\u9019\u5c0d\u65bc\u4fdd\u6301\u6578\u64da\u5b8c\u6574\u6027\u975e\u5e38\u91cd\u8981\u3002<\/li>\n<li><strong>\u5168\u6587\u7d22\u5f15\uff1a<\/strong>\u5168\u6587\u7d22\u5f15\u7528\u65bc\u52a0\u901f\u5c0d\u6587\u672c\u6578\u64da\u7684\u67e5\u8a62\uff0c\u7279\u5225\u662f\u5728\u9700\u8981\u9032\u884c\u95dc\u9375\u5b57\u641c\u7d22\u7684\u60c5\u6cc1\u4e0b\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b4%a2%e5%bc%95%e7%9a%84%e5%b7%a5%e4%bd%9c%e5%8e%9f%e7%90%86-AlPwRPvwte\">\u7d22\u5f15\u7684\u5de5\u4f5c\u539f\u7406<\/h2>\n<p>\u7576\u57f7\u884c\u67e5\u8a62\u6642\uff0cSQL Server\u6703\u6839\u64da\u67e5\u8a62\u7684\u689d\u4ef6\u4f86\u6c7a\u5b9a\u662f\u5426\u4f7f\u7528\u7d22\u5f15\u3002\u5982\u679c\u67e5\u8a62\u4e2d\u6d89\u53ca\u7684\u5217\u6709\u7d22\u5f15\uff0cSQL Server\u5c07\u4f7f\u7528\u8a72\u7d22\u5f15\u4f86\u5feb\u901f\u5b9a\u4f4d\u6578\u64da\uff0c\u800c\u4e0d\u662f\u9032\u884c\u5168\u8868\u6383\u63cf\u3002\u9019\u6a23\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002<\/p>\n<h3 id=\"%e7%b4%a2%e5%bc%95%e7%9a%84%e5%89%b5%e5%bb%ba-AlPwRPvwte\">\u7d22\u5f15\u7684\u5275\u5efa<\/h3>\n<p>\u5728SQL Server\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u6cd5\u5275\u5efa\u7d22\u5f15\uff1a<\/p>\n<pre><code>CREATE INDEX index_name\nON table_name (column1, column2, ...);<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u540d\u70ba\u201cCustomers\u201d\u7684\u8868\uff0c\u6211\u5011\u5e0c\u671b\u5728\u201cLastName\u201d\u5217\u4e0a\u5275\u5efa\u4e00\u500b\u975e\u805a\u96c6\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>CREATE NONCLUSTERED INDEX IX_Customers_LastName\nON Customers (LastName);<\/code><\/pre>\n<h3 id=\"%e7%b4%a2%e5%bc%95%e7%9a%84%e7%b6%ad%e8%ad%b7-AlPwRPvwte\">\u7d22\u5f15\u7684\u7dad\u8b77<\/h3>\n<p>\u96d6\u7136\u7d22\u5f15\u53ef\u4ee5\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\uff0c\u4f46\u5b83\u5011\u4e5f\u6703\u589e\u52a0\u6578\u64da\u63d2\u5165\u3001\u66f4\u65b0\u548c\u522a\u9664\u64cd\u4f5c\u7684\u6210\u672c\u3002\u9019\u662f\u56e0\u70ba\u6bcf\u6b21\u5c0d\u8868\u9032\u884c\u4fee\u6539\u6642\uff0c\u76f8\u95dc\u7684\u7d22\u5f15\u4e5f\u5fc5\u9808\u66f4\u65b0\u3002\u56e0\u6b64\uff0c\u5728\u8a2d\u8a08\u6578\u64da\u5eab\u6642\uff0c\u9700\u8981\u5e73\u8861\u7d22\u5f15\u7684\u6578\u91cf\u548c\u6027\u80fd\u3002<\/p>\n<h2 id=\"%e7%b4%a2%e5%bc%95%e7%9a%84%e6%9c%80%e4%bd%b3%e5%af%a6%e8%b8%90-AlPwRPvwte\">\u7d22\u5f15\u7684\u6700\u4f73\u5be6\u8e10<\/h2>\n<ul>\n<li>\u5b9a\u671f\u5206\u6790\u67e5\u8a62\u6027\u80fd\uff0c\u78ba\u5b9a\u54ea\u4e9b\u67e5\u8a62\u53ef\u4ee5\u53d7\u76ca\u65bc\u7d22\u5f15\u3002<\/li>\n<li>\u907f\u514d\u5728\u7d93\u5e38\u8b8a\u66f4\u7684\u5217\u4e0a\u5275\u5efa\u7d22\u5f15\uff0c\u4ee5\u6e1b\u5c11\u7dad\u8b77\u6210\u672c\u3002<\/li>\n<li>\u4f7f\u7528\u5305\u542b\u5217\u4f86\u64f4\u5c55\u975e\u805a\u96c6\u7d22\u5f15\uff0c\u9019\u6a23\u53ef\u4ee5\u907f\u514d\u67e5\u8a62\u6642\u7684\u56de\u8868\u64cd\u4f5c\u3002<\/li>\n<li>\u5b9a\u671f\u91cd\u5efa\u6216\u91cd\u7d44\u7d22\u5f15\uff0c\u4ee5\u4fdd\u6301\u5176\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-AlPwRPvwte\">\u7d50\u8ad6<\/h2>\n<p>\u7d22\u5f15\u662fSQL Server\u4e2d\u5be6\u73fe\u6578\u64da\u8a2a\u554f\u512a\u5316\u7684\u91cd\u8981\u5de5\u5177\u3002\u901a\u904e\u5408\u7406\u5730\u4f7f\u7528\u548c\u7dad\u8b77\u7d22\u5f15\uff0c\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u6578\u64da\u6aa2\u7d22\u7684\u6548\u7387\uff0c\u5f9e\u800c\u63d0\u5347\u6574\u9ad4\u61c9\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u3002\u5728\u8a2d\u8a08\u6578\u64da\u5eab\u6642\uff0c\u61c9\u4ed4\u7d30\u8003\u616e\u7d22\u5f15\u7684\u4f7f\u7528\uff0c\u4ee5\u9054\u5230\u6700\u4f73\u7684\u6027\u80fd\u5e73\u8861\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc<code><a href=\"https:\/\/server.hk\">VPS<\/a><\/code>\u548c<code><a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a><\/code>\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5982\u4f55\u4f7f\u7528SQL Server\u7d22\u5f15\u4f86\u512a\u5316\u6578\u64da\u8a2a\u554f\uff0c\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\uff0c\u6e1b\u5c11\u97ff\u61c9\u6642\u9593\uff0c\u63d0\u5347\u6574\u9ad4\u6578\u64da\u5eab\u6548\u7387\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-139065","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/139065","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=139065"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/139065\/revisions"}],"predecessor-version":[{"id":139066,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/139065\/revisions\/139066"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=139065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=139065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=139065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}