{"id":6252,"date":"2024-11-14T11:29:47","date_gmt":"2024-11-14T03:29:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6252\/"},"modified":"2024-11-14T11:29:47","modified_gmt":"2024-11-14T03:29:47","slug":"mysql%e5%a6%82%e4%bd%95%e6%9f%a5%e8%af%a2%e5%88%97%e5%90%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6252\/","title":{"rendered":"mysql\u5982\u4f55\u67e5\u8be2\u5217\u540d"},"content":{"rendered":"<p><strong>\u5982\u4f55\u67e5\u8be2  \u4e2d\u7684\u5217\u540d<\/strong><\/p>\n<p>\u5728 MySQL \u4e2d\uff0c\u67e5\u8be2\u5217\u540d\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>SHOW COLUMNS FROM [\u8868\u540d];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u547d\u4ee4\u8bed\u6cd5<\/strong><\/p>\n<ul>\n<li> <strong>SHOW COLUMNS<\/strong>\uff1a\u547d\u4ee4\u5173\u952e\u5b57\uff0c\u7528\u4e8e\u663e\u793a\u8868\u4e2d\u7684\u5217\u3002<\/li>\n<li> <strong>FROM [\u8868\u540d]<\/strong>\uff1a\u6307\u5b9a\u8981\u67e5\u8be2\u5217\u540d\u7684\u8868\u540d\u79f0\u3002<\/li>\n<\/ul>\n<p><strong>\u547d\u4ee4\u793a\u4f8b<\/strong><\/p>\n<pre>SHOW COLUMNS FROM customers;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u547d\u4ee4\u8f93\u51fa<\/strong><\/p>\n<p>\u6267\u884c\u6b64\u547d\u4ee4\u5c06\u8f93\u51fa\u8be5\u8868\u4e2d\u6240\u6709\u5217\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li> <strong>Field<\/strong>\uff1a\u5217\u540d\u3002<\/li>\n<li> <strong>Type<\/strong>\uff1a\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002<\/li>\n<li> <strong>Collation<\/strong>\uff1a\u5217\u7684\u5b57\u7b26\u96c6\u548c\u6821\u5bf9\u89c4\u5219\u3002<\/li>\n<li> <strong>Null<\/strong>\uff1a\u662f\u5426\u5141\u8bb8\u7a7a\u503c\u3002<\/li>\n<li> <strong>Key<\/strong>\uff1a\u662f\u5426\u4e3a\u4e3b\u952e\u6216\u5916\u952e\u3002<\/li>\n<li> <strong>Default<\/strong>\uff1a\u5217\u7684\u9ed8\u8ba4\u503c\u3002<\/li>\n<li> <strong>Extra<\/strong>\uff1a\u5176\u4ed6\u4fe1\u606f\uff0c\u4f8b\u5982\u81ea\u589e\u6216\u552f\u4e00\u6027\u7ea6\u675f\u3002<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u4f7f\u7528\u65b9\u6cd5<\/strong><\/p>\n<p>\u9664\u4e86\u4e0a\u8ff0\u547d\u4ee4\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u67e5\u8be2 MySQL \u4e2d\u7684\u5217\u540d\uff1a<\/p>\n<ul>\n<li> <strong>INFORMATION_SCHEMA.COLUMNS \u8868<\/strong>\uff1a\u7cfb\u7edf\u8868\uff0c\u5305\u542b\u6240\u6709\u8868\u7684\u5217\u540d\u4fe1\u606f\u3002<\/li>\n<li> <strong>DESCRIBE [\u8868\u540d]<\/strong>\uff1a\u663e\u793a\u8868\u7684\u7ed3\u6784\uff0c\u5305\u62ec\u5217\u540d\u3002<\/li>\n<li> <strong>EXPLAIN SELECT &#8230;<\/strong>\uff1a\u663e\u793a\u67e5\u8be2\u6267\u884c\u8ba1\u5212\uff0c\u5176\u4e2d\u5305\u542b\u6d89\u53ca\u7684\u5217\u540d\u3002<\/li>\n<\/ul>\n<p><strong>\u5c0f\u63d0\u793a<\/strong><\/p>\n<ul>\n<li>\u547d\u4ee4\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528\u901a\u914d\u7b26\uff08\u5982 %\uff09\u6765\u5339\u914d\u5217\u540d\u7684\u4e00\u90e8\u5206\u3002<\/li>\n<li>LIKE \u64cd\u4f5c\u7b26\u53ef\u7528\u4e8e\u5339\u914d\u6a21\u5f0f\u7684\u5217\u540d\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u67e5\u8be2\u5217\u540d\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>\u5982\u4f55\u67e5\u8be2 \u4e2d\u7684\u5217\u540d \u5728 MySQL \u4e2d\uff0c\u67e5\u8be2\u5217\u540d\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a SHOW COLUMNS FROM [\u8868\u540d]; \u767b\u5f55\u540e\u590d\u5236 \u547d\u4ee4\u8bed\u6cd5 SHOW COLUMNS\uff1a\u547d\u4ee4\u5173\u952e\u5b57\uff0c\u7528\u4e8e\u663e\u793a\u8868\u4e2d\u7684\u5217\u3002 FROM [\u8868\u540d]\uff1a\u6307\u5b9a\u8981\u67e5\u8be2\u5217\u540d\u7684\u8868\u540d\u79f0\u3002 \u547d\u4ee4\u793a\u4f8b SHOW COLUMNS FROM customers; \u767b\u5f55\u540e\u590d\u5236 \u547d\u4ee4\u8f93\u51fa \u6267\u884c\u6b64\u547d\u4ee4\u5c06\u8f93\u51fa\u8be5\u8868\u4e2d\u6240\u6709\u5217\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\uff1a Field\uff1a\u5217\u540d\u3002 Type\uff1a\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002 Collation\uff1a\u5217\u7684\u5b57\u7b26\u96c6\u548c\u6821\u5bf9\u89c4\u5219\u3002 Null\uff1a\u662f\u5426\u5141\u8bb8\u7a7a\u503c\u3002 Key\uff1a\u662f\u5426\u4e3a\u4e3b\u952e\u6216\u5916\u952e\u3002 Default\uff1a\u5217\u7684\u9ed8\u8ba4\u503c\u3002 Extra\uff1a\u5176\u4ed6\u4fe1\u606f\uff0c\u4f8b\u5982\u81ea\u589e\u6216\u552f\u4e00\u6027\u7ea6\u675f\u3002 \u5176\u4ed6\u4f7f\u7528\u65b9\u6cd5 \u9664\u4e86\u4e0a\u8ff0\u547d\u4ee4\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u67e5\u8be2 MySQL \u4e2d\u7684\u5217\u540d\uff1a INFORMATION_SCHEMA.COLUMNS \u8868\uff1a\u7cfb\u7edf\u8868\uff0c\u5305\u542b\u6240\u6709\u8868\u7684\u5217\u540d\u4fe1\u606f\u3002 DESCRIBE [\u8868\u540d]\uff1a\u663e\u793a\u8868\u7684\u7ed3\u6784\uff0c\u5305\u62ec\u5217\u540d\u3002 EXPLAIN SELECT &#8230;\uff1a\u663e\u793a\u67e5\u8be2\u6267\u884c\u8ba1\u5212\uff0c\u5176\u4e2d\u5305\u542b\u6d89\u53ca\u7684\u5217\u540d\u3002 \u5c0f\u63d0\u793a \u547d\u4ee4\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002 \u53ef\u4ee5\u4f7f\u7528\u901a\u914d\u7b26\uff08\u5982 %\uff09\u6765\u5339\u914d\u5217\u540d\u7684\u4e00\u90e8\u5206\u3002 LIKE \u64cd\u4f5c\u7b26\u53ef\u7528\u4e8e\u5339\u914d\u6a21\u5f0f\u7684\u5217\u540d\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u67e5\u8be2\u5217\u540d\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6252","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6252","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=6252"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6252\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}