{"id":161551,"date":"2024-11-04T07:22:39","date_gmt":"2024-11-03T23:22:39","guid":{"rendered":"https:\/\/server.hk\/cnblog\/161551\/"},"modified":"2024-11-04T07:22:40","modified_gmt":"2024-11-03T23:22:40","slug":"sql-server%e7%b4%a2%e5%bc%95%e7%b5%90%e6%a7%8b%e5%8f%8a%e5%85%b6%e4%bd%bf%e7%94%a8-2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/161551\/","title":{"rendered":"SQL Server\u7d22\u5f15\u7d50\u69cb\u53ca\u5176\u4f7f\u7528"},"content":{"rendered":"<h1 id=\"sql-server%e7%b4%a2%e5%bc%95%e7%b5%90%e6%a7%8b%e5%8f%8a%e5%85%b6%e4%bd%bf%e7%94%a8-gjQHueiqnj\">SQL Server\u7d22\u5f15\u7d50\u69cb\u53ca\u5176\u4f7f\u7528<\/h1>\n<p>\u5728\u8cc7\u6599\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0c\u7d22\u5f15\u662f\u4e00\u7a2e\u91cd\u8981\u7684\u8cc7\u6599\u7d50\u69cb\uff0c\u80fd\u5920\u986f\u8457\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002SQL Server\u4f5c\u70ba\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u95dc\u806f\u8cc7\u6599\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5176\u7d22\u5f15\u7d50\u69cb\u7684\u8a2d\u8a08\u548c\u4f7f\u7528\u5c0d\u65bc\u8cc7\u6599\u7684\u5b58\u53d6\u6548\u7387\u81f3\u95dc\u91cd\u8981\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eSQL Server\u7684\u7d22\u5f15\u7d50\u69cb\u53ca\u5176\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e7%b4%a2%e5%bc%95%ef%bc%9f-gjQHueiqnj\">\u4ec0\u9ebc\u662f\u7d22\u5f15\uff1f<\/h2>\n<p>\u7d22\u5f15\u662f\u4e00\u7a2e\u8cc7\u6599\u7d50\u69cb\uff0c\u65e8\u5728\u52a0\u901f\u8cc7\u6599\u6aa2\u7d22\u7684\u901f\u5ea6\u3002\u5b83\u985e\u4f3c\u65bc\u66f8\u7c4d\u7684\u76ee\u9304\uff0c\u80fd\u5920\u5e6b\u52a9\u8cc7\u6599\u5eab\u5feb\u901f\u5b9a\u4f4d\u5230\u6240\u9700\u7684\u8cc7\u6599\u884c\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-gjQHueiqnj\">\u7d22\u5f15\u7684\u985e\u578b<\/h2>\n<h3 id=\"1-%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95-gjQHueiqnj\">1. \u805a\u96c6\u7d22\u5f15<\/h3>\n<p>\u805a\u96c6\u7d22\u5f15\u662f\u5c07\u8cc7\u6599\u884c\u7684\u7269\u7406\u9806\u5e8f\u8207\u7d22\u5f15\u7684\u908f\u8f2f\u9806\u5e8f\u76f8\u7d50\u5408\u7684\u7d22\u5f15\u3002\u6bcf\u500b\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\u3002\u805a\u96c6\u7d22\u5f15\u901a\u5e38\u7528\u65bc\u4e3b\u9375\u6216\u7d93\u5e38\u7528\u65bc\u7be9\u9078\u7684\u5217\u3002<\/p>\n<pre><code>CREATE CLUSTERED INDEX idx_Clustered ON Employees(EmployeeID);<\/code><\/pre>\n<h3 id=\"2-%e9%9d%9e%e8%81%9a%e9%9b%86%e7%b4%a2%e5%bc%95-gjQHueiqnj\">2. \u975e\u805a\u96c6\u7d22\u5f15<\/h3>\n<p>\u975e\u805a\u96c6\u7d22\u5f15\u5247\u662f\u5c07\u7d22\u5f15\u7684\u908f\u8f2f\u9806\u5e8f\u8207\u8cc7\u6599\u884c\u7684\u7269\u7406\u9806\u5e8f\u5206\u958b\u3002\u6bcf\u500b\u8868\u53ef\u4ee5\u6709\u591a\u500b\u975e\u805a\u96c6\u7d22\u5f15\uff0c\u9019\u4f7f\u5f97\u5b83\u5011\u5728\u67e5\u8a62\u6027\u80fd\u4e0a\u975e\u5e38\u9748\u6d3b\u3002\u975e\u805a\u96c6\u7d22\u5f15\u901a\u5e38\u7528\u65bc\u67e5\u8a62\u4e2d\u7d93\u5e38\u4f7f\u7528\u7684\u5217\u3002<\/p>\n<pre><code>CREATE NONCLUSTERED INDEX idx_NonClustered ON Employees(LastName);<\/code><\/pre>\n<h3 id=\"3-%e5%94%af%e4%b8%80%e7%b4%a2%e5%bc%95-gjQHueiqnj\">3. \u552f\u4e00\u7d22\u5f15<\/h3>\n<p>\u552f\u4e00\u7d22\u5f15\u78ba\u4fdd\u7d22\u5f15\u5217\u4e2d\u7684\u6240\u6709\u503c\u90fd\u662f\u552f\u4e00\u7684\u3002\u9019\u5c0d\u65bc\u9632\u6b62\u91cd\u8907\u8cc7\u6599\u975e\u5e38\u6709\u7528\u3002\u552f\u4e00\u7d22\u5f15\u53ef\u4ee5\u662f\u805a\u96c6\u7684\u6216\u975e\u805a\u96c6\u7684\u3002<\/p>\n<pre><code>CREATE UNIQUE INDEX idx_Unique ON Employees(Email);<\/code><\/pre>\n<h3 id=\"4-%e5%85%a8%e6%96%87%e7%b4%a2%e5%bc%95-gjQHueiqnj\">4. \u5168\u6587\u7d22\u5f15<\/h3>\n<p>\u5168\u6587\u7d22\u5f15\u7528\u65bc\u5c0d\u5927\u91cf\u6587\u672c\u8cc7\u6599\u9032\u884c\u9ad8\u6548\u7684\u67e5\u8a62\u3002\u5b83\u652f\u6301\u5c0d\u6587\u672c\u9032\u884c\u8907\u96dc\u7684\u67e5\u8a62\uff0c\u5982\u6a21\u7cca\u67e5\u8a62\u548c\u77ed\u8a9e\u67e5\u8a62\u3002<\/p>\n<pre><code>CREATE FULLTEXT INDEX ON Documents(Content) KEY INDEX idx_Clustered;<\/code><\/pre>\n<h2 id=\"%e7%b4%a2%e5%bc%95%e7%9a%84%e4%bd%bf%e7%94%a8-gjQHueiqnj\">\u7d22\u5f15\u7684\u4f7f\u7528<\/h2>\n<p>\u5728SQL Server\u4e2d\uff0c\u6b63\u78ba\u4f7f\u7528\u7d22\u5f15\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6700\u4f73\u5be6\u8e10\uff1a<\/p>\n<ul>\n<li><strong>\u9078\u64c7\u5408\u9069\u7684\u5217\uff1a<\/strong>\u5728\u7d93\u5e38\u7528\u65bc\u67e5\u8a62\u7684\u5217\u4e0a\u5275\u5efa\u7d22\u5f15\uff0c\u7279\u5225\u662f\u90a3\u4e9b\u5728WHERE\u5b50\u53e5\u3001JOIN\u689d\u4ef6\u6216ORDER BY\u5b50\u53e5\u4e2d\u4f7f\u7528\u7684\u5217\u3002<\/li>\n<li><strong>\u907f\u514d\u904e\u591a\u7684\u7d22\u5f15\uff1a<\/strong>\u96d6\u7136\u7d22\u5f15\u53ef\u4ee5\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\uff0c\u4f46\u904e\u591a\u7684\u7d22\u5f15\u6703\u5f71\u97ff\u8cc7\u6599\u7684\u63d2\u5165\u3001\u66f4\u65b0\u548c\u522a\u9664\u64cd\u4f5c\u7684\u6027\u80fd\u3002\u56e0\u6b64\uff0c\u61c9\u6839\u64da\u5be6\u969b\u9700\u6c42\u4f86\u9078\u64c7\u7d22\u5f15\u3002<\/li>\n<li><strong>\u5b9a\u671f\u91cd\u5efa\u548c\u91cd\u7d44\u7d22\u5f15\uff1a<\/strong>\u96a8\u8457\u8cc7\u6599\u7684\u589e\u9577\u548c\u8b8a\u66f4\uff0c\u7d22\u5f15\u53ef\u80fd\u6703\u8b8a\u5f97\u788e\u7247\u5316\u3002\u5b9a\u671f\u91cd\u5efa\u6216\u91cd\u7d44\u7d22\u5f15\u53ef\u4ee5\u4fdd\u6301\u5176\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-gjQHueiqnj\">\u7d50\u8ad6<\/h2>\n<p>SQL Server\u7684\u7d22\u5f15\u7d50\u69cb\u662f\u63d0\u9ad8\u8cc7\u6599\u6aa2\u7d22\u6548\u7387\u7684\u91cd\u8981\u5de5\u5177\u3002\u901a\u904e\u5408\u7406\u5730\u8a2d\u8a08\u548c\u4f7f\u7528\u7d22\u5f15\uff0c\u53ef\u4ee5\u986f\u8457\u6539\u5584\u67e5\u8a62\u6027\u80fd\uff0c\u5f9e\u800c\u63d0\u5347\u6574\u9ad4\u7cfb\u7d71\u7684\u6548\u80fd\u3002\u4e86\u89e3\u4e0d\u540c\u985e\u578b\u7684\u7d22\u5f15\u53ca\u5176\u4f7f\u7528\u60c5\u5883\uff0c\u5c0d\u65bc\u8cc7\u6599\u5eab\u7ba1\u7406\u8005\u4f86\u8aaa\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002<\/p>\n<p>\u5982\u9700\u9032\u4e00\u6b65\u4e86\u89e3\u6709\u95dc<code>VPS<\/code>\u3001<code>\u9999\u6e2fVPS<\/code>\u3001<code>\u4f3a\u670d\u5668<\/code>\u3001<code>\u4e91\u4f3a\u670d\u5668<\/code>\u7b49\u4e3b\u984c\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\u7d22\u5f15\u7d50\u69cb\u53ca\u5176\u4f7f\u7528\uff0c\u63d0\u5347\u67e5\u8a62\u6548\u7387\uff0c\u512a\u5316\u6578\u64da\u5b58\u53d6\uff0c\u5be6\u73fe\u66f4\u5feb\u7684\u6578\u64da\u8655\u7406\u548c\u7ba1\u7406\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-161551","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/161551","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=161551"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/161551\/revisions"}],"predecessor-version":[{"id":161552,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/161551\/revisions\/161552"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=161551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=161551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=161551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}