{"id":138917,"date":"2024-10-31T16:29:17","date_gmt":"2024-10-31T08:29:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/138917\/"},"modified":"2024-10-31T16:29:18","modified_gmt":"2024-10-31T08:29:18","slug":"sql-server%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e6%8c%87%e7%a4%ba%e7%b0%a1%e4%bb%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/138917\/","title":{"rendered":"SQL Server\u805a\u96c6\u7d22\u5f15\u7684\u6307\u793a\u7c21\u4ecb"},"content":{"rendered":"<h1 id=\"sql-server%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e6%8c%87%e7%a4%ba%e7%b0%a1%e4%bb%8b-ZKNuVPKjQF\">SQL Server\u805a\u96c6\u7d22\u5f15\u7684\u6307\u793a\u7c21\u4ecb<\/h1>\n<p>\u5728\u8cc7\u6599\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0c\u7d22\u5f15\u662f\u4e00\u7a2e\u91cd\u8981\u7684\u7d50\u69cb\uff0c\u7528\u65bc\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002SQL Server\u4e2d\u7684\u805a\u96c6\u7d22\u5f15\uff08Clustered Index\uff09\u662f\u6700\u5e38\u7528\u7684\u7d22\u5f15\u985e\u578b\u4e4b\u4e00\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u805a\u96c6\u7d22\u5f15\u7684\u6982\u5ff5\u3001\u7279\u6027\u53ca\u5176\u5728SQL Server\u4e2d\u7684\u61c9\u7528\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%ef%bc%9f-ZKNuVPKjQF\">\u4ec0\u9ebc\u662f\u805a\u96c6\u7d22\u5f15\uff1f<\/h2>\n<p>\u805a\u96c6\u7d22\u5f15\u662f\u4e00\u7a2e\u5c07\u8cc7\u6599\u8868\u4e2d\u7684\u8cc7\u6599\u884c\u6309\u7167\u7279\u5b9a\u7684\u9806\u5e8f\u9032\u884c\u5b58\u5132\u7684\u7d22\u5f15\u3002\u8207\u975e\u805a\u96c6\u7d22\u5f15\u4e0d\u540c\uff0c\u805a\u96c6\u7d22\u5f15\u6703\u6539\u8b8a\u8cc7\u6599\u7684\u7269\u7406\u5b58\u5132\u9806\u5e8f\u3002\u6bcf\u500b\u8cc7\u6599\u8868\u53ea\u80fd\u6709\u4e00\u500b\u805a\u96c6\u7d22\u5f15\uff0c\u56e0\u70ba\u8cc7\u6599\u884c\u7684\u7269\u7406\u9806\u5e8f\u53ea\u80fd\u6709\u4e00\u7a2e\u6392\u5217\u65b9\u5f0f\u3002<\/p>\n<h2 id=\"%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e7%89%b9%e6%80%a7-ZKNuVPKjQF\">\u805a\u96c6\u7d22\u5f15\u7684\u7279\u6027<\/h2>\n<ul>\n<li><strong>\u552f\u4e00\u6027\uff1a<\/strong>\u805a\u96c6\u7d22\u5f15\u7684\u9375\u503c\u5fc5\u9808\u662f\u552f\u4e00\u7684\uff0c\u9019\u6a23\u624d\u80fd\u78ba\u4fdd\u8cc7\u6599\u7684\u552f\u4e00\u6027\u3002<\/li>\n<li><strong>\u6392\u5e8f\uff1a<\/strong>\u8cc7\u6599\u8868\u4e2d\u7684\u8cc7\u6599\u6703\u6839\u64da\u805a\u96c6\u7d22\u5f15\u7684\u9375\u503c\u9032\u884c\u6392\u5e8f\uff0c\u9019\u4f7f\u5f97\u7bc4\u570d\u67e5\u8a62\u7684\u6027\u80fd\u5927\u5e45\u63d0\u5347\u3002<\/li>\n<li><strong>\u5b58\u5132\uff1a<\/strong>\u805a\u96c6\u7d22\u5f15\u7684\u8449\u7bc0\u9ede\u5305\u542b\u4e86\u8cc7\u6599\u884c\u7684\u5be6\u969b\u6578\u64da\uff0c\u9019\u610f\u5473\u8457\u67e5\u8a62\u6642\u4e0d\u9700\u8981\u984d\u5916\u7684\u67e5\u627e\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%89%b5%e5%bb%ba%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95-ZKNuVPKjQF\">\u5982\u4f55\u5275\u5efa\u805a\u96c6\u7d22\u5f15<\/h2>\n<p>\u5728SQL Server\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u6cd5\u4f86\u5275\u5efa\u805a\u96c6\u7d22\u5f15\uff1a<\/p>\n<pre><code>CREATE CLUSTERED INDEX index_name\nON table_name (column_name);<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u540d\u70ba\u201cCustomers\u201d\u7684\u8cc7\u6599\u8868\uff0c\u6211\u5011\u5e0c\u671b\u5728\u201cCustomerID\u201d\u5217\u4e0a\u5275\u5efa\u805a\u96c6\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u8a9e\u53e5\uff1a<\/p>\n<pre><code>CREATE CLUSTERED INDEX IX_Customers_CustomerID\nON Customers (CustomerID);<\/code><\/pre>\n<h2 id=\"%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e5%84%aa%e7%bc%ba%e9%bb%9e-ZKNuVPKjQF\">\u805a\u96c6\u7d22\u5f15\u7684\u512a\u7f3a\u9ede<\/h2>\n<h3 id=\"%e5%84%aa%e9%bb%9e-ZKNuVPKjQF\">\u512a\u9ede<\/h3>\n<ul>\n<li><strong>\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\uff1a<\/strong>\u805a\u96c6\u7d22\u5f15\u80fd\u5920\u52a0\u901f\u57fa\u65bc\u7d22\u5f15\u5217\u7684\u67e5\u8a62\uff0c\u7279\u5225\u662f\u7bc4\u570d\u67e5\u8a62\u3002<\/li>\n<li><strong>\u6e1b\u5c11I\/O\u64cd\u4f5c\uff1a<\/strong>\u7531\u65bc\u8cc7\u6599\u884c\u7684\u5be6\u969b\u6578\u64da\u5b58\u5132\u5728\u7d22\u5f15\u4e2d\uff0c\u67e5\u8a62\u6642\u53ef\u4ee5\u6e1b\u5c11\u5c0d\u78c1\u789f\u7684I\/O\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%bc%ba%e9%bb%9e-ZKNuVPKjQF\">\u7f3a\u9ede<\/h3>\n<ul>\n<li><strong>\u63d2\u5165\u6027\u80fd\u4e0b\u964d\uff1a<\/strong>\u7531\u65bc\u8cc7\u6599\u9700\u8981\u6309\u7167\u805a\u96c6\u7d22\u5f15\u7684\u9806\u5e8f\u9032\u884c\u5b58\u5132\uff0c\u63d2\u5165\u64cd\u4f5c\u53ef\u80fd\u6703\u8b8a\u5f97\u8f03\u6162\u3002<\/li>\n<li><strong>\u66f4\u65b0\u6027\u80fd\u5f71\u97ff\uff1a<\/strong>\u5982\u679c\u66f4\u65b0\u7684\u5217\u662f\u805a\u96c6\u7d22\u5f15\u7684\u4e00\u90e8\u5206\uff0c\u5247\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u6392\u5e8f\u8cc7\u6599\uff0c\u5f71\u97ff\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95%e7%9a%84%e6%9c%80%e4%bd%b3%e5%af%a6%e8%b8%90-ZKNuVPKjQF\">\u805a\u96c6\u7d22\u5f15\u7684\u6700\u4f73\u5be6\u8e10<\/h2>\n<ul>\n<li>\u9078\u64c7\u5177\u6709\u552f\u4e00\u6027\u7684\u5217\u4f5c\u70ba\u805a\u96c6\u7d22\u5f15\u7684\u9375\u503c\u3002<\/li>\n<li>\u907f\u514d\u5728\u7d93\u5e38\u66f4\u65b0\u7684\u5217\u4e0a\u5275\u5efa\u805a\u96c6\u7d22\u5f15\uff0c\u4ee5\u6e1b\u5c11\u6027\u80fd\u5f71\u97ff\u3002<\/li>\n<li>\u8003\u616e\u4f7f\u7528\u8907\u5408\u7d22\u5f15\uff0c\u5c07\u591a\u500b\u5217\u7d44\u5408\u5728\u4e00\u8d77\uff0c\u4ee5\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-ZKNuVPKjQF\">\u7d50\u8ad6<\/h2>\n<p>\u805a\u96c6\u7d22\u5f15\u5728SQL Server\u4e2d\u626e\u6f14\u8457\u81f3\u95dc\u91cd\u8981\u7684\u89d2\u8272\uff0c\u80fd\u5920\u986f\u8457\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002\u4e86\u89e3\u5176\u7279\u6027\u3001\u512a\u7f3a\u9ede\u53ca\u6700\u4f73\u5be6\u8e10\uff0c\u5c0d\u65bc\u8cc7\u6599\u5eab\u7ba1\u7406\u8005\u4f86\u8aaa\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u900f\u904e\u5408\u7406\u7684\u8a2d\u8a08\u548c\u4f7f\u7528\u805a\u96c6\u7d22\u5f15\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u63d0\u5347\u8cc7\u6599\u5eab\u7684\u6574\u9ad4\u6027\u80fd\u3002<\/p>\n<p>\u5982\u9700\u9032\u4e00\u6b65\u4e86\u89e3\u6709\u95dc<code>VPS<\/code>\u3001<code>\u9999\u6e2fvps<\/code>\u6216\u5176\u4ed6<code>\u4f3a\u670d\u5668<\/code>\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3SQL Server\u805a\u96c6\u7d22\u5f15\u7684\u57fa\u672c\u6982\u5ff5\u3001\u7279\u6027\u53ca\u5176\u5728\u6578\u64da\u5eab\u6027\u80fd\u4e2d\u7684\u91cd\u8981\u6027\uff0c\u63d0\u5347\u67e5\u8a62\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-138917","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/138917","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=138917"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/138917\/revisions"}],"predecessor-version":[{"id":138918,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/138917\/revisions\/138918"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=138917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=138917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=138917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}