{"id":319836,"date":"2024-01-19T10:42:29","date_gmt":"2024-01-19T02:42:29","guid":{"rendered":"https:\/\/www.idc.net\/help\/319836\/"},"modified":"2024-01-19T10:42:29","modified_gmt":"2024-01-19T02:42:29","slug":"%e6%95%99%e6%82%a8mysql-alter%e8%af%ad%e5%8f%a5%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/319836\/","title":{"rendered":"\u6559\u60a8MySQL alter\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"<p>\u5b66\u4e60MySQL\u6570\u636e\u5e93\uff0c\u5404\u79cd\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u6cd5\u662f\u9996\u5148\u9700\u8981\u638c\u63e1\u7684\uff0c\u4e0b\u6587\u5c31\u4e3a\u60a8\u4ecb\u7ecdMySQL alter\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u5982\u679c\u60a8\u5bf9MySQL alter\u8bed\u53e5\u4e0d\u662f\u5f88\u4e86\u89e3\u7684\u8bdd\uff0c\u4e0d\u59a8\u4e00\u770b\uff0c\u76f8\u4fe1\u53ef\u4ee5\u8ba9\u60a8\u5bf9MySQL alter\u8bed\u53e5\u7684\u4f7f\u7528\u6709\u4e00\u4e2a\u6e05\u695a\u5730\u8ba4\u8bc6\u3002<\/p>\n<p>\/\/\u4e3b\u952e<\/p>\n<p>alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);<br \/> \/\/\u589e\u52a0\u4e00\u4e2a\u65b0\u5217<\/p>\n<p>alter table t2 add d timestamp;<br \/> alter table infos add ex tinyint not null default '0';<br \/> \/\/\u5220\u9664\u5217<\/p>\n<p>alter table t2 drop column c;<br \/> \/\/\u91cd\u547d\u540d\u5217<\/p>\n<p>alter table t1 change a b integer;<\/p>\n<p>\/\/\u6539\u53d8\u5217\u7684\u7c7b\u578b<\/p>\n<p>alter table t1 change b b bigint not null;<br \/> alter table infos change list list tinyint not null default '0';<\/p>\n<p>\/\/\u91cd\u547d\u540d\u8868<\/p>\n<p>alter table t1 rename t2;<br \/> \u52a0\u7d22\u5f15<\/p>\n<p>mysql&gt; alter table tablename change depno depno int(5) not null;<br \/> mysql&gt; alter table tablename add index \u7d22\u5f15\u540d (\u5b57\u6bb5\u540d1[\uff0c\u5b57\u6bb5\u540d2 \u2026]);<br \/> mysql&gt; alter table tablename add index emp_name (name);<br \/> \u52a0\u4e3b\u5173\u952e\u5b57\u7684\u7d22\u5f15<\/p>\n<p>mysql&gt; alter table tablename add primary key(id);<br \/> \u52a0***\u9650\u5236\u6761\u4ef6\u7684\u7d22\u5f15<\/p>\n<p>mysql&gt; alter table tablename add unique emp_name2(cardnumber);<br \/> \u5220\u9664\u67d0\u4e2a\u7d22\u5f15<\/p>\n<p>mysql&gt;alter table tablename drop index emp_name;<br \/> \u4fee\u6539\u8868\uff1a<\/p>\n<p>\u589e\u52a0\u5b57\u6bb5\uff1a<\/p>\n<p>mysql&gt; ALTER TABLE table_name ADD field_name field_type;<br \/> \u4fee\u6539\u539f\u5b57\u6bb5\u540d\u79f0\u53ca\u7c7b\u578b\uff1a<\/p>\n<p>mysql&gt; ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;<br \/> \u5220\u9664\u5b57\u6bb5\uff1a<\/p>\n<p>mysql&gt; ALTER TABLE table_name DROP field_name;<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL alter\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u6cd5\u7684\u4ecb\u7ecd\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u3010\u7f16\u8f91\u63a8\u8350\u3011<\/p>\n<p>\u53d6\u5f97MySQL\u8868\u4fe1\u606f\u7684\u8bed\u53e5<\/p>\n<p>PHP\u4e2d\u5e38\u7528\u5230\u7684\u4e00\u4e9bMySQL\u8bed\u53e5<\/p>\n<p>mysql UPDATE\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u6cd5<\/p>\n<p>mysql\u63d2\u5165Clob\u5b57\u6bb5\u7684\u5b9e\u4f8b<\/p>\n<p>MySQL\u4e2dINSERT\u7684\u4e00\u822c\u7528\u6cd5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b66\u4e60MySQL\u6570\u636e\u5e93\uff0c\u5404\u79cd\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u6cd5\u662f\u9996\u5148\u9700\u8981\u638c\u63e1\u7684\uff0c\u4e0b\u6587\u5c31\u4e3a\u60a8\u4ecb\u7ecdMySQL alter\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7038],"tags":[],"class_list":["post-319836","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/319836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=319836"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/319836\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=319836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=319836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=319836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}