{"id":5476,"date":"2024-11-14T11:32:56","date_gmt":"2024-11-14T03:32:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5476\/"},"modified":"2024-11-14T11:32:56","modified_gmt":"2024-11-14T03:32:56","slug":"mysql%e6%80%8e%e4%b9%88%e7%94%9f%e6%88%90er%e5%9b%be","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5476\/","title":{"rendered":"mysql\u600e\u4e48\u751f\u6210er\u56fe"},"content":{"rendered":"<blockquote><p>\n  \u5728 mysql \u4e2d\u751f\u6210 er \u56fe\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a\u83b7\u53d6\u6570\u636e\u5e93\u67b6\u6784\u4fe1\u606f\u89e3\u6790\u67b6\u6784\u4fe1\u606f\u521b\u5efa er \u56fe\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052903122310981.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u751f\u6210er\u56fe\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u751f\u6210er\u56fe\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u4e2d\u751f\u6210 ER \u56fe<\/strong><\/p>\n<p><strong>\u5982\u4f55\u751f\u6210 ER \u56fe\uff1f<\/strong><\/p>\n<p>\u5728 MySQL \u4e2d\u751f\u6210 ER \u56fe\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a<\/p>\n<ol>\n<li> <strong>\u83b7\u53d6\u6570\u636e\u5e93\u67b6\u6784\u4fe1\u606f\uff1a<\/strong>\u4f7f\u7528 SHOW CREATE TABLE \u8bed\u53e5\u83b7\u53d6\u6240\u6709\u8868\u7684\u67b6\u6784\u4fe1\u606f\u3002<\/li>\n<li> <strong>\u89e3\u6790\u67b6\u6784\u4fe1\u606f\uff1a<\/strong>\u4f7f\u7528\u89e3\u6790\u5668\u6216\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u8868\u540d\u3001\u5217\u540d\u3001\u6570\u636e\u7c7b\u578b\u3001\u4e3b\u952e\u548c\u5916\u952e\u5173\u7cfb\u7b49\u4fe1\u606f\u3002<\/li>\n<li> <strong>\u521b\u5efa ER \u56fe\uff1a<\/strong>\u4f7f\u7528 ER \u56fe\u5efa\u6a21\u5de5\u5177\uff08\u5982 MySQL Workbench\u3001DbDiagram.io \u6216 Lucidchart\uff09\u5bfc\u5165\u89e3\u6790\u540e\u7684\u4fe1\u606f\u5e76\u521b\u5efa ER \u56fe\u3002<\/li>\n<\/ol>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u83b7\u53d6\u6570\u636e\u5e93\u67b6\u6784\u4fe1\u606f<\/strong><\/p>\n<p>\u5728 MySQL \u547d\u4ee4\u884c\u4e2d\uff0c\u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>SHOW CREATE TABLE table_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u5bf9\u4e8e customers \u8868\uff0c\u6267\u884c\uff1a<\/p>\n<pre>SHOW CREATE TABLE customers;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u751f\u6210\u4e00\u4e2a\u5305\u542b\u8868\u67b6\u6784\u4fe1\u606f\u7684\u8f93\u51fa\u3002<\/p>\n<p><strong>\u6b65\u9aa4 2\uff1a\u89e3\u6790\u67b6\u6784\u4fe1\u606f<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b63\u5219\u8868\u8fbe\u5f0f\u89e3\u6790\u8f93\u51fa\uff1a<\/p>\n<pre>TABLEs+`(.*)`s*((.*))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5339\u914d\u7ec4 1 \u5305\u542b\u8868\u540d\uff0c\u5339\u914d\u7ec4 2 \u5305\u542b\u5217\u5b9a\u4e49\u3002\u5bf9\u4e8e\u5217\u5b9a\u4e49\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b63\u5219\u8868\u8fbe\u5f0f\u89e3\u6790\uff1a<\/p>\n<pre>`(.*)`s+([^s]+)s*(NOTs+NULL)?<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5339\u914d\u7ec4 1 \u5305\u542b\u5217\u540d\uff0c\u5339\u914d\u7ec4 2 \u5305\u542b\u6570\u636e\u7c7b\u578b\uff0c\u5339\u914d\u7ec4 3 \u8868\u793a\u662f\u5426 NOT NULL\u3002<\/p>\n<p><strong>\u6b65\u9aa4 3\uff1a\u521b\u5efa ER \u56fe<\/strong><\/p>\n<p>\u5c06\u89e3\u6790\u540e\u7684\u4fe1\u606f\u5bfc\u5165 ER \u56fe\u5efa\u6a21\u5de5\u5177\u4e2d\uff0c\u5de5\u5177\u4f1a\u81ea\u52a8\u521b\u5efa ER \u56fe\u3002<\/p>\n<p><strong>\u989d\u5916\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u5bfc\u51fa\u529f\u80fd\u5c06 ER \u56fe\u5bfc\u51fa\u4e3a\u56fe\u50cf\u6216 PDF \u6587\u4ef6\u3002<\/li>\n<li>ER \u56fe\u5e94\u5b9a\u671f\u66f4\u65b0\uff0c\u4ee5\u53cd\u6620\u6570\u636e\u5e93\u67b6\u6784\u7684\u66f4\u6539\u3002<\/li>\n<li>\u4f7f\u7528\u5728\u7ebf\u5de5\u5177\uff08\u5982 Visual Paradigms\uff09\u7b80\u5316 ER \u56fe\u7684\u521b\u5efa\u8fc7\u7a0b\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u751f\u6210er\u56fe\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\u751f\u6210 er \u56fe\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a\u83b7\u53d6\u6570\u636e\u5e93\u67b6\u6784\u4fe1\u606f\u89e3\u6790\u67b6\u6784\u4fe1\u606f\u521b\u5efa er \u56fe MySQL \u4e2d\u751f\u6210 ER \u56fe \u5982\u4f55\u751f\u6210 ER \u56fe\uff1f \u5728 MySQL \u4e2d\u751f\u6210 ER \u56fe\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a \u83b7\u53d6\u6570\u636e\u5e93\u67b6\u6784\u4fe1\u606f\uff1a\u4f7f\u7528 SHOW CREATE TABLE \u8bed\u53e5\u83b7\u53d6\u6240\u6709\u8868\u7684\u67b6\u6784\u4fe1\u606f\u3002 \u89e3\u6790\u67b6\u6784\u4fe1\u606f\uff1a\u4f7f\u7528\u89e3\u6790\u5668\u6216\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u8868\u540d\u3001\u5217\u540d\u3001\u6570\u636e\u7c7b\u578b\u3001\u4e3b\u952e\u548c\u5916\u952e\u5173\u7cfb\u7b49\u4fe1\u606f\u3002 \u521b\u5efa ER \u56fe\uff1a\u4f7f\u7528 ER \u56fe\u5efa\u6a21\u5de5\u5177\uff08\u5982 MySQL Workbench\u3001DbDiagram.io \u6216 Lucidchart\uff09\u5bfc\u5165\u89e3\u6790\u540e\u7684\u4fe1\u606f\u5e76\u521b\u5efa ER \u56fe\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a \u6b65\u9aa4 1\uff1a\u83b7\u53d6\u6570\u636e\u5e93\u67b6\u6784\u4fe1\u606f \u5728 MySQL \u547d\u4ee4\u884c\u4e2d\uff0c\u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff1a SHOW CREATE TABLE table_name; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u5bf9\u4e8e customers \u8868\uff0c\u6267\u884c\uff1a SHOW CREATE TABLE customers; \u767b\u5f55\u540e\u590d\u5236 [&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-5476","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5476","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=5476"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5476\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}