{"id":383,"date":"2021-05-05T18:35:26","date_gmt":"2021-05-05T10:35:26","guid":{"rendered":"http:\/\/112.124.66.68\/?p=383"},"modified":"2021-05-05T18:35:26","modified_gmt":"2021-05-05T10:35:26","slug":"%e3%80%90%e9%98%bf%e9%87%8c%e6%bb%b4%e6%bb%b4%e9%9d%a2%e8%af%95%e8%a1%a5%e7%bc%ba%e3%80%91mysql%e7%b4%a2%e5%bc%95%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2021\/05\/05\/%e3%80%90%e9%98%bf%e9%87%8c%e6%bb%b4%e6%bb%b4%e9%9d%a2%e8%af%95%e8%a1%a5%e7%bc%ba%e3%80%91mysql%e7%b4%a2%e5%bc%95%e9%97%ae%e9%a2%98\/","title":{"rendered":"\u3010\u963f\u91cc\u6ef4\u6ef4\u9762\u8bd5\u8865\u7f3a\u3011MySQL\u7d22\u5f15\u95ee\u9898"},"content":{"rendered":"\n<p>\u7d22\u5f15\u95ee\u9898<br>\u7d22\u5f15\u662f\u5bf9\u6570\u636e\u5e93\u8868\u4e2d\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u7684\u503c\u8fdb\u884c\u6392\u5e8f\u7684\u7ed3\u6784\uff0c\u5efa\u7acb\u7d22\u5f15\u6709\u52a9\u4e8e\u5feb\u901f\u83b7\u53d6\u4fe1\u606f\u3002<br>\u4f60\u4e5f\u53ef\u4ee5\u8fd9\u6837\u7406\u89e3\uff1a\u7d22\u5f15\u5c31\u662f\u52a0\u5feb\u68c0\u7d22\u8868\u4e2d\u6570\u636e\u7684\u65b9\u6cd5\u3002\u6570\u636e\u5e93\u7684\u7d22\u5f15\u7c7b\u4f3c\u4e8e\u4e66\u7c4d\u7684\u7d22\u5f15\u3002\u5728\u4e66\u7c4d\u4e2d\uff0c<br>\u7d22\u5f15\u5141\u8bb8\u7528\u6237\u4e0d\u5fc5\u7ffb\u9605\u5b8c\u6574\u4e2a\u4e66\u5c31\u80fd\u8fc5\u901f\u5730\u627e\u5230\u6240\u9700\u8981\u7684\u4fe1\u606f\u3002\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u7d22\u5f15\u4e5f\u5141\u8bb8\u6570\u636e\u5e93\u7a0b\u5e8f\u8fc5<br>\u901f\u5730\u627e\u5230\u8868\u4e2d\u7684\u6570\u636e\uff0c\u800c\u4e0d\u5fc5\u626b\u63cf\u6574\u4e2a\u6570\u636e\u5e93\u3002<br>mysql \u6709<strong>4\u79cd\u4e0d\u540c\u7684\u7d22\u5f15<\/strong><br><strong>\u4e3b\u952e\u7d22\u5f15\uff08PRIMARY\uff09<\/strong><br>\u6570\u636e\u5217\u4e0d\u5141\u8bb8\u91cd\u590d\uff0c\u4e0d\u5141\u8bb8\u4e3aNULL\uff0c\u4e00\u4e2a\u8868\u53ea\u80fd\u6709\u4e00\u4e2a\u4e3b\u952e\u3002<\/p>\n\n\n\n<p><br><strong>\u552f\u4e00\u7d22\u5f15\uff08UNIQUE\uff09<\/strong><br>\u6570\u636e\u5217\u4e0d\u5141\u8bb8\u91cd\u590d\uff0c\u5141\u8bb8\u4e3aNULL\u503c\uff0c\u4e00\u4e2a\u8868\u5141\u8bb8\u591a\u4e2a\u5217\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u3002<br>\u53ef\u4ee5\u901a\u8fc7 ALTER TABLE table_name ADD UNIQUE (column); \u521b\u5efa\u552f\u4e00\u7d22\u5f15<br>\u53ef\u4ee5\u901a\u8fc7 ALTER TABLE table_name ADD UNIQUE (column1,column2); \u521b\u5efa\u552f\u4e00\u7ec4\u5408\u7d22\u5f15<\/p>\n\n\n\n<p><br><strong>\u666e\u901a\u7d22\u5f15\uff08INDEX\uff09<\/strong><br>\u53ef\u4ee5\u901a\u8fc7 ALTER TABLE table_name ADD INDEX index_name (column); \u521b\u5efa\u666e\u901a\u7d22\u5f15<br>\u53ef\u4ee5\u901a\u8fc7 ALTER TABLE table_name ADD INDEX index_name(column1, column2,column3); \u521b\u5efa\u7ec4\u5408\u7d22\u5f15<\/p>\n\n\n\n<p><br><strong>\u5168\u6587\u7d22\u5f15\uff08FULLTEXT\uff09<\/strong><br>\u53ef\u4ee5\u901a\u8fc7 ALTER TABLE table_name ADD FULLTEXT (column); \u521b\u5efa\u5168\u6587\u7d22\u5f15<\/p>\n\n\n\n<p><br>\u7d22\u5f15\u5e76\u975e\u662f\u8d8a\u591a\u8d8a\u597d\uff0c\u521b\u5efa\u7d22\u5f15\u4e5f\u9700\u8981\u8017\u8d39\u8d44\u6e90<strong>\u4e00\u662f\u589e\u52a0\u4e86\u6570\u636e\u5e93\u7684\u5b58\u50a8\u7a7a\u95f4<\/strong>\uff0c<strong>\u4e8c\u662f\u5728\u63d2\u5165\u548c\u5220\u9664\u65f6<\/strong>\u8981\u82b1\u8d39\u8f83\u591a\u7684\u65f6\u95f4\u7ef4\u62a4\u7d22\u5f15<br>\u7d22\u5f15\u52a0\u5feb\u6570\u636e\u5e93\u7684\u68c0\u7d22\u901f\u5ea6<br>\u7d22\u5f15\u964d\u4f4e\u4e86\u63d2\u5165\u3001\u5220\u9664\u3001\u4fee\u6539\u7b49\u7ef4\u62a4\u4efb\u52a1\u7684\u901f\u5ea6<br><strong>\u552f\u4e00\u7d22\u5f15\u53ef\u4ee5\u786e\u4fdd\u6bcf\u4e00\u884c\u6570\u636e\u7684\u552f\u4e00\u6027<\/strong><br>\u901a\u8fc7\u4f7f\u7528\u7d22\u5f15\uff0c\u53ef\u4ee5\u5728<strong>\u67e5\u8be2\u7684\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u4f18\u5316\u9690\u85cf\u5668\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u6027\u80fd<\/strong><br>\u7d22\u5f15\u9700\u8981<strong>\u5360\u7269\u7406\u548c\u6570\u636e\u7a7a\u95f4<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d22\u5f15\u95ee\u9898\u7d22\u5f15\u662f\u5bf9\u6570\u636e\u5e93\u8868\u4e2d\u4e00\u4e2a\u6216&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":201,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-383","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media\/201"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}