{"id":5879,"date":"2024-11-14T12:51:56","date_gmt":"2024-11-14T04:51:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5879\/"},"modified":"2024-11-14T12:51:56","modified_gmt":"2024-11-14T04:51:56","slug":"sql%e7%b4%a2%e5%bc%95%e6%80%8e%e4%b9%88%e6%9f%a5%e8%af%a2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5879\/","title":{"rendered":"sql\u7d22\u5f15\u600e\u4e48\u67e5\u8be2"},"content":{"rendered":"<blockquote><p>\n  \u5728 mysql \u4e2d\uff0c\u4f7f\u7528 show index \u8bed\u53e5\u53ef\u4ee5\u67e5\u8be2\u8868\u4e2d\u7684\u7d22\u5f15\u3002\u6b65\u9aa4\u5305\u62ec\uff1a\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u8f93\u5165 show index from \u8bed\u53e5\uff0c\u5176\u4e2d \u662f\u8981\u67e5\u8be2\u7684\u8868\u7684\u540d\u79f0\u3002\u8f93\u51fa\u7ed3\u679c\u96c6\u5305\u542b\u7d22\u5f15\u540d\u79f0\u3001\u5217\u540d\u79f0\u3001\u7d22\u5f15\u7c7b\u578b\u3001\u552f\u4e00\u6027\u3001\u57fa\u6570\u3001\u5b57\u6bb5\u7b49\u4fe1\u606f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060321332445631.jpg\" class=\"aligncenter\" title=\"sql\u7d22\u5f15\u600e\u4e48\u67e5\u8be2\u63d2\u56fe\" alt=\"sql\u7d22\u5f15\u600e\u4e48\u67e5\u8be2\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u7d22\u5f15\u67e5\u8be2\u65b9\u6cd5<\/strong><\/p>\n<p><strong>\u5982\u4f55\u67e5\u8be2 SQL \u7d22\u5f15\uff1f<\/strong><\/p>\n<p>\u5728 MySQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 SHOW INDEX \u8bed\u53e5\u6765\u67e5\u8be2\u8868\u4e2d\u7684\u7d22\u5f15\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li> <strong>\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a<\/strong>\u4f7f\u7528\u60a8\u7684\u6570\u636e\u5e93\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fde\u63a5\u5230 MySQL \u6570\u636e\u5e93\u3002<\/li>\n<li> <strong>\u8f93\u5165 SHOW INDEX \u8bed\u53e5\uff1a<\/strong>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/li>\n<\/ol>\n<pre>SHOW INDEX FROM &lt;table&gt;;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d <\/p>\n<ol>\n<li> <strong>\u6309\u4e0b Enter\uff1a<\/strong>\u6309\u4e0b Enter \u952e\u6267\u884c\u547d\u4ee4\u3002<\/li>\n<\/ol>\n<p><strong>\u8f93\u51fa\u89e3\u91ca\uff1a<\/strong><\/p>\n<p>SHOW INDEX \u8bed\u53e5\u5c06\u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\uff0c\u5176\u4e2d\u5305\u542b\u6709\u5173\u8868\u4e2d\u6bcf\u4e2a\u7d22\u5f15\u7684\u4fe1\u606f\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li> <strong>\u7d22\u5f15\u540d\u79f0\uff1a<\/strong>\u7d22\u5f15\u7684\u540d\u79f0\u3002<\/li>\n<li> <strong>\u5217\u540d\u79f0\uff1a<\/strong>\u7d22\u5f15\u6240\u5728\u7684\u5217\u3002<\/li>\n<li> <strong>\u7d22\u5f15\u7c7b\u578b\uff1a<\/strong>\u7d22\u5f15\u7684\u7c7b\u578b\uff08\u4f8b\u5982\uff0c\u54c8\u5e0c\u7d22\u5f15\u3001B \u6811\u7d22\u5f15\uff09\u3002<\/li>\n<li> <strong>\u552f\u4e00\u6027\uff1a<\/strong>\u7d22\u5f15\u662f\u5426\u552f\u4e00\u3002<\/li>\n<li> <strong>\u57fa\u6570\uff1a<\/strong>\u7d22\u5f15\u4e2d\u7684\u4e0d\u540c\u503c\u7684\u6570\u91cf\u3002<\/li>\n<li> <strong>\u5b57\u6bb5\uff1a<\/strong>\u7d22\u5f15\u4f7f\u7528\u7684\u5b57\u6bb5\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a customers \u7684\u8868\uff0c\u5176\u4e2d\u6709 customer_name \u548c customer_email \u5217\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u67e5\u8be2\u8be5\u8868\u7684\u7d22\u5f15\uff1a<\/p>\n<pre>SHOW INDEX FROM customers;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre>+--------------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+\n| Table         | Non_unique | Key_name         | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null |\n+--------------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+\n| customers     | 0          | PRIMARY         | 1            | customer_id | A         | 1000        | NULL     | NULL    |      |\n| customers     | 1          | customer_name    | 1            | customer_name | A         | 500         | NULL     | NULL    | YES   |\n| customers     | 1          | customer_email   | 1            | customer_email | A         | 400         | NULL     | NULL    | YES   |\n+--------------+------------+------------------+--------------+-------------+-----------+-------------+----------+--------+------+<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u8f93\u51fa\u663e\u793a customers \u8868\u4e0a\u6709\u4e09\u4e2a\u7d22\u5f15\uff1a<\/p>\n<ul>\n<li>\u4e3b\u952e\u7d22\u5f15 PRIMARY \u5728 customer_id \u5217\u4e0a\u3002<\/li>\n<li>\u552f\u4e00\u7d22\u5f15 customer_name \u5728 customer_name \u5217\u4e0a\u3002<\/li>\n<li>\u552f\u4e00\u7d22\u5f15 customer_email \u5728 customer_email \u5217\u4e0a\u3002<\/li>\n<\/ul>\n<table>\n  \u662f\u60a8\u8981\u67e5\u8be2\u5176\u7d22\u5f15\u7684\u8868\u7684\u540d\u79f0\u3002<br \/>\n<\/table>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u7d22\u5f15\u600e\u4e48\u67e5\u8be2\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 mysql \u4e2d\uff0c\u4f7f\u7528 show index \u8bed\u53e5\u53ef\u4ee5\u67e5\u8be2\u8868\u4e2d\u7684\u7d22\u5f15\u3002\u6b65\u9aa4\u5305\u62ec\uff1a\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u8f93\u5165 show index from \u8bed\u53e5\uff0c\u5176\u4e2d \u662f\u8981\u67e5\u8be2\u7684\u8868\u7684\u540d\u79f0\u3002\u8f93\u51fa\u7ed3\u679c\u96c6\u5305\u542b\u7d22\u5f15\u540d\u79f0\u3001\u5217\u540d\u79f0\u3001\u7d22\u5f15\u7c7b\u578b\u3001\u552f\u4e00\u6027\u3001\u57fa\u6570\u3001\u5b57\u6bb5\u7b49\u4fe1\u606f\u3002 SQL \u7d22\u5f15\u67e5\u8be2\u65b9\u6cd5 \u5982\u4f55\u67e5\u8be2 SQL \u7d22\u5f15\uff1f \u5728 MySQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 SHOW INDEX \u8bed\u53e5\u6765\u67e5\u8be2\u8868\u4e2d\u7684\u7d22\u5f15\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a \u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a\u4f7f\u7528\u60a8\u7684\u6570\u636e\u5e93\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fde\u63a5\u5230 MySQL \u6570\u636e\u5e93\u3002 \u8f93\u5165 SHOW INDEX \u8bed\u53e5\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u4ee5\u4e0b\u8bed\u53e5\uff1a SHOW INDEX FROM &lt;table&gt;; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d \u6309\u4e0b Enter\uff1a\u6309\u4e0b Enter \u952e\u6267\u884c\u547d\u4ee4\u3002 \u8f93\u51fa\u89e3\u91ca\uff1a SHOW INDEX \u8bed\u53e5\u5c06\u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u96c6\uff0c\u5176\u4e2d\u5305\u542b\u6709\u5173\u8868\u4e2d\u6bcf\u4e2a\u7d22\u5f15\u7684\u4fe1\u606f\uff0c\u5305\u62ec\uff1a \u7d22\u5f15\u540d\u79f0\uff1a\u7d22\u5f15\u7684\u540d\u79f0\u3002 \u5217\u540d\u79f0\uff1a\u7d22\u5f15\u6240\u5728\u7684\u5217\u3002 \u7d22\u5f15\u7c7b\u578b\uff1a\u7d22\u5f15\u7684\u7c7b\u578b\uff08\u4f8b\u5982\uff0c\u54c8\u5e0c\u7d22\u5f15\u3001B \u6811\u7d22\u5f15\uff09\u3002 \u552f\u4e00\u6027\uff1a\u7d22\u5f15\u662f\u5426\u552f\u4e00\u3002 \u57fa\u6570\uff1a\u7d22\u5f15\u4e2d\u7684\u4e0d\u540c\u503c\u7684\u6570\u91cf\u3002 \u5b57\u6bb5\uff1a\u7d22\u5f15\u4f7f\u7528\u7684\u5b57\u6bb5\u3002 \u793a\u4f8b\uff1a \u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a customers \u7684\u8868\uff0c\u5176\u4e2d\u6709 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5879","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5879"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5879\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}