{"id":6391,"date":"2024-11-14T10:24:27","date_gmt":"2024-11-14T02:24:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6391\/"},"modified":"2024-11-14T10:24:27","modified_gmt":"2024-11-14T02:24:27","slug":"mysql%e4%bf%ae%e6%94%b9%e5%ad%97%e6%ae%b5%e5%90%8d%e7%9a%84%e8%af%ad%e5%8f%a5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6391\/","title":{"rendered":"mysql\u4fee\u6539\u5b57\u6bb5\u540d\u7684\u8bed\u53e5"},"content":{"rendered":"<blockquote><p>\n  mysql \u4fee\u6539\u5b57\u6bb5\u540d\u79f0\u7684\u8bed\u53e5\u662f\uff1aalter table \u8868\u540d change \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b\u3002\u8be5\u64cd\u4f5c\u5c06\u5f71\u54cd\u8be5\u5b57\u6bb5\u7684\u7d22\u5f15\u548c\u7ea6\u675f\uff0c\u5e76\u9700\u8981\u8003\u8651\u65b0\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u517c\u5bb9\u6027\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/01\/2024080106341990755.jpg\" class=\"aligncenter\" title=\"mysql\u4fee\u6539\u5b57\u6bb5\u540d\u7684\u8bed\u53e5\u63d2\u56fe\" alt=\"mysql\u4fee\u6539\u5b57\u6bb5\u540d\u7684\u8bed\u53e5\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u4fee\u6539\u5b57\u6bb5\u540d\u8bed\u53e5<\/strong><\/p>\n<p>\u4fee\u6539 MySQL \u6570\u636e\u5e93\u8868\u4e2d\u5b57\u6bb5\u540d\u79f0\u7684\u8bed\u53e5\u4e3a\uff1a<\/p>\n<pre>ALTER TABLE \u8868\u540d CHANGE \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>ALTER TABLE people CHANGE first_name name VARCHAR(255);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>ALTER TABLE \u8868\u540d\uff1a<\/strong>\u6307\u5b9a\u8981\u4fee\u6539\u5b57\u6bb5\u7684\u8868\u3002<\/li>\n<li> <strong>CHANGE \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d\uff1a<\/strong>\u6307\u5b9a\u8981\u4fee\u6539\u7684\u65e7\u5b57\u6bb5\u540d\u548c\u65b0\u7684\u5b57\u6bb5\u540d\u3002<\/li>\n<li> <strong>\u6570\u636e\u7c7b\u578b\uff1a<\/strong>\u6307\u5b9a\u65b0\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u65b0\u5b57\u6bb5\u540d\u4e0d\u5e94\u4e0e\u8868\u4e2d\u5df2\u5b58\u5728\u7684\u5b57\u6bb5\u540d\u51b2\u7a81\u3002<\/li>\n<li>\u65b0\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u517c\u5bb9\u65e7\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5426\u5219\u5c06\u5bfc\u81f4\u6216\u8f6c\u6362\u9519\u8bef\u3002<\/li>\n<li>\u5982\u679c\u65e7\u5b57\u6bb5\u540d\u662f\u4e3b\u952e\u6216\u5916\u952e\uff0c\u5219\u9700\u8981\u66f4\u65b0\u76f8\u5e94\u7684\u7ea6\u675f\u3002<\/li>\n<li>\u8be5\u64cd\u4f5c\u5c06\u5f71\u54cd\u6240\u6709\u4f7f\u7528\u8be5\u5b57\u6bb5\u7684\u7d22\u5f15\u548c\u7ea6\u675f\u3002<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u9009\u9879\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>ALTER TABLE &#8230; RENAME COLUMN\uff1a<\/strong>\u8be5\u8bed\u6cd5\u5df2\u88ab\u5f03\u7528\uff0c\u63a8\u8350\u4f7f\u7528 CHANGE \u8bed\u6cd5\u3002<\/li>\n<li> <strong>ALTER TABLE &#8230; MODIFY COLUMN\uff1a<\/strong>\u53ef\u4ee5\u540c\u65f6\u4fee\u6539\u5b57\u6bb5\u540d\u548c\u6570\u636e\u7c7b\u578b\u3002\u8bed\u6cd5\u4e3a\uff1a<\/li>\n<\/ul>\n<pre>ALTER TABLE \u8868\u540d MODIFY COLUMN \u65b0\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>ALTER TABLE people MODIFY COLUMN name VARCHAR(255);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4fee\u6539\u5b57\u6bb5\u540d\u7684\u8bed\u53e5\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>mysql \u4fee\u6539\u5b57\u6bb5\u540d\u79f0\u7684\u8bed\u53e5\u662f\uff1aalter table \u8868\u540d change \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b\u3002\u8be5\u64cd\u4f5c\u5c06\u5f71\u54cd\u8be5\u5b57\u6bb5\u7684\u7d22\u5f15\u548c\u7ea6\u675f\uff0c\u5e76\u9700\u8981\u8003\u8651\u65b0\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u517c\u5bb9\u6027\u3002 MySQL \u4fee\u6539\u5b57\u6bb5\u540d\u8bed\u53e5 \u4fee\u6539 MySQL \u6570\u636e\u5e93\u8868\u4e2d\u5b57\u6bb5\u540d\u79f0\u7684\u8bed\u53e5\u4e3a\uff1a ALTER TABLE \u8868\u540d CHANGE \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b; \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b\uff1a ALTER TABLE people CHANGE first_name name VARCHAR(255); \u767b\u5f55\u540e\u590d\u5236 \u8bed\u6cd5\uff1a ALTER TABLE \u8868\u540d\uff1a\u6307\u5b9a\u8981\u4fee\u6539\u5b57\u6bb5\u7684\u8868\u3002 CHANGE \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d\uff1a\u6307\u5b9a\u8981\u4fee\u6539\u7684\u65e7\u5b57\u6bb5\u540d\u548c\u65b0\u7684\u5b57\u6bb5\u540d\u3002 \u6570\u636e\u7c7b\u578b\uff1a\u6307\u5b9a\u65b0\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u3002 \u6ce8\u610f\u4e8b\u9879\uff1a \u65b0\u5b57\u6bb5\u540d\u4e0d\u5e94\u4e0e\u8868\u4e2d\u5df2\u5b58\u5728\u7684\u5b57\u6bb5\u540d\u51b2\u7a81\u3002 \u65b0\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u517c\u5bb9\u65e7\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5426\u5219\u5c06\u5bfc\u81f4\u6216\u8f6c\u6362\u9519\u8bef\u3002 \u5982\u679c\u65e7\u5b57\u6bb5\u540d\u662f\u4e3b\u952e\u6216\u5916\u952e\uff0c\u5219\u9700\u8981\u66f4\u65b0\u76f8\u5e94\u7684\u7ea6\u675f\u3002 \u8be5\u64cd\u4f5c\u5c06\u5f71\u54cd\u6240\u6709\u4f7f\u7528\u8be5\u5b57\u6bb5\u7684\u7d22\u5f15\u548c\u7ea6\u675f\u3002 \u5176\u4ed6\u9009\u9879\uff1a ALTER TABLE &#8230; RENAME COLUMN\uff1a\u8be5\u8bed\u6cd5\u5df2\u88ab\u5f03\u7528\uff0c\u63a8\u8350\u4f7f\u7528 CHANGE \u8bed\u6cd5\u3002 ALTER TABLE &#8230; MODIFY [&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-6391","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6391","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=6391"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6391\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}