{"id":5864,"date":"2024-11-14T08:18:25","date_gmt":"2024-11-14T00:18:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5864\/"},"modified":"2024-11-14T08:18:25","modified_gmt":"2024-11-14T00:18:25","slug":"sql%e6%80%8e%e4%b9%88%e6%9f%a5%e8%af%a2%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9a%84%e6%89%80%e6%9c%89%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5864\/","title":{"rendered":"sql\u600e\u4e48\u67e5\u8be2\u6570\u636e\u5e93\u7684\u6240\u6709\u8868"},"content":{"rendered":"<blockquote><p>\n  \u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u8868\u7684\u6b65\u9aa4\uff1a\u8fde\u63a5\u76ee\u6807\u6570\u636e\u5e93\u3002\u6267\u884c\u67e5\u8be2\uff1aselect table_name from information_schema.tables where table_schema = &#8216;database_name&#8217;\u3002\u67e5\u770b\u67e5\u8be2\u7ed3\u679c\u4e2d\u7684\u8868\u540d\u5217\u8868\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060321092568239.jpg\" class=\"aligncenter\" title=\"sql\u600e\u4e48\u67e5\u8be2\u6570\u636e\u5e93\u7684\u6240\u6709\u8868\u63d2\u56fe\" alt=\"sql\u600e\u4e48\u67e5\u8be2\u6570\u636e\u5e93\u7684\u6240\u6709\u8868\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u8868\u7684\u6b65\u9aa4<\/strong><\/p>\n<p>\u8981\u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u8fde\u63a5\u5230\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u4f7f\u7528\u9002\u5f53\u7684 SQL \u5ba2\u6237\u7aef\u5de5\u5177\uff08\u5982 MySQL Workbench\uff09\u8fde\u63a5\u5230\u76ee\u6807\u6570\u636e\u5e93\u3002<\/p>\n<p><strong>2. \u6267\u884c\u67e5\u8be2<\/strong><\/p>\n<p>\u6267\u884c\u4ee5\u4e0b\u67e5\u8be2\u4ee5\u83b7\u53d6\u6240\u6709\u8868\u7684\u5217\u8868\uff1a<\/p>\n<pre>SELECT table_name\nFROM information_schema.tables\nWHERE table_schema = 'database_name';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0cdatabase_name \u662f\u8981\u67e5\u8be2\u5176\u8868\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002<\/p>\n<p><strong>3. \u67e5\u770b\u7ed3\u679c<\/strong><\/p>\n<p>\u67e5\u8be2\u7ed3\u679c\u5c06\u8f93\u51fa\u4e00\u4e2a\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6570\u636e\u5e93\u4e2d\u6240\u6709\u8868\u7684\u8868\u540d\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u67e5\u8be2\u540d\u4e3a &#8220;my_database&#8221; \u7684\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/p>\n<pre>SELECT table_name\nFROM information_schema.tables\nWHERE table_schema = 'my_database';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6267\u884c\u6b64\u67e5\u8be2\u540e\uff0c\u5c06\u663e\u793a\u8be5\u6570\u636e\u5e93\u4e2d\u6240\u6709\u8868\u7684\u8868\u540d\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u600e\u4e48\u67e5\u8be2\u6570\u636e\u5e93\u7684\u6240\u6709\u8868\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>\u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u8868\u7684\u6b65\u9aa4\uff1a\u8fde\u63a5\u76ee\u6807\u6570\u636e\u5e93\u3002\u6267\u884c\u67e5\u8be2\uff1aselect table_name from information_schema.tables where table_schema = &#8216;database_name&#8217;\u3002\u67e5\u770b\u67e5\u8be2\u7ed3\u679c\u4e2d\u7684\u8868\u540d\u5217\u8868\u3002 SQL \u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u8868\u7684\u6b65\u9aa4 \u8981\u67e5\u8be2\u6240\u6709\u6570\u636e\u5e93\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u8fde\u63a5\u5230\u6570\u636e\u5e93 \u4f7f\u7528\u9002\u5f53\u7684 SQL \u5ba2\u6237\u7aef\u5de5\u5177\uff08\u5982 MySQL Workbench\uff09\u8fde\u63a5\u5230\u76ee\u6807\u6570\u636e\u5e93\u3002 2. \u6267\u884c\u67e5\u8be2 \u6267\u884c\u4ee5\u4e0b\u67e5\u8be2\u4ee5\u83b7\u53d6\u6240\u6709\u8868\u7684\u5217\u8868\uff1a SELECT table_name FROM information_schema.tables WHERE table_schema = &#8216;database_name&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cdatabase_name \u662f\u8981\u67e5\u8be2\u5176\u8868\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 3. \u67e5\u770b\u7ed3\u679c \u67e5\u8be2\u7ed3\u679c\u5c06\u8f93\u51fa\u4e00\u4e2a\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u6570\u636e\u5e93\u4e2d\u6240\u6709\u8868\u7684\u8868\u540d\u3002 \u793a\u4f8b \u4f8b\u5982\uff0c\u8981\u67e5\u8be2\u540d\u4e3a &#8220;my_database&#8221; \u7684\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a SELECT table_name FROM information_schema.tables WHERE table_schema = &#8216;my_database&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u6267\u884c\u6b64\u67e5\u8be2\u540e\uff0c\u5c06\u663e\u793a\u8be5\u6570\u636e\u5e93\u4e2d\u6240\u6709\u8868\u7684\u8868\u540d\u3002 \u4ee5\u4e0a\u5c31\u662fsql\u600e\u4e48\u67e5\u8be2\u6570\u636e\u5e93\u7684\u6240\u6709\u8868\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-5864","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5864","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=5864"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5864\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}