{"id":29,"date":"2013-03-28T11:47:08","date_gmt":"2013-03-28T03:47:08","guid":{"rendered":"http:\/\/www.zyuns.com\/?p=29"},"modified":"2015-02-15T20:51:34","modified_gmt":"2015-02-15T12:51:34","slug":"e6-80-bb-e7-bb-93-e4-b8-80-e4-b8-8b-e5-af-b9mysql-e8-a1-a8-e7-bb-93-e6-9e-84-e7-9a-84-e4-bf-ae-e6-94-b9-e6-93-8d-e4-bd-9c","status":"publish","type":"post","link":"https:\/\/www.siediyer.cn\/?p=29","title":{"rendered":"\u603b\u7ed3\u4e00\u4e0b\u5bf9mysql\u8868\u7ed3\u6784\u7684\u4fee\u6539\u64cd\u4f5c"},"content":{"rendered":"<p>\u603b\u7ed3\u4e00\u4e0b\u5bf9mysql\u8868\u7ed3\u6784\u7684\u4fee\u6539\u64cd\u4f5c\uff0c\u5305\u62ec\u5bf9<strong>\u5b57\u6bb5<\/strong>\u53ca<strong>\u7d22\u5f15<\/strong>\u7684\u4fee\u6539\u64cd\u4f5c\uff1a<\/p>\n<p>\u6dfb\u52a0\u5b57\u6bb5\uff1a<\/p>\n<pre class=\"lang:default decode:true\">alter table `user_movement_log` Add column GatewayId int not null default 0 AFTER `Regionid` (\u5728\u54ea\u4e2a\u5b57\u6bb5\u540e\u9762\u6dfb\u52a0)<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5220\u9664\u5b57\u6bb5\uff1a<\/p>\n<pre class=\"lang:default decode:true\">alter table `user_movement_log` drop column Gatewayid<\/pre>\n<p>&nbsp;<\/p>\n<p>\u8c03\u6574\u5b57\u6bb5\u987a\u5e8f\uff1a<\/p>\n<pre class=\"lang:default decode:true\">ALTER TABLE `user_movement_log` CHANGE `GatewayId` `GatewayId` int not null default 0 AFTER RegionID<\/pre>\n<p>&nbsp;<\/p>\n<p>\/\/\u4e3b\u952e<\/p>\n<pre class=\"lang:default decode:true\">alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);<\/pre>\n<p>&nbsp;<\/p>\n<p>\/\/\u589e\u52a0\u4e00\u4e2a\u65b0\u5217<\/p>\n<pre class=\"lang:default decode:true\">alter table t2 add newfield timestamp;  (\u7b80\u5355\u8bed\u6cd5\uff0c\u53ea\u6307\u5b9a\u65b0\u6dfb\u5b57\u6bb5newfield \u7c7b\u578b\u4e3atimestamp)\nalter table infos add newfield tinyint not null default '0'; \uff08\u540c\u65f6\u6307\u5b9a\u5b57\u6bb5null\u5c5e\u6027\u3001\u9ed8\u8ba4\u503c\uff09<\/pre>\n<p>&nbsp;<\/p>\n<p>\/\/\u5220\u9664\u5217<\/p>\n<pre class=\"lang:default decode:true\">alter table t2 drop column c; \uff08\u5220\u9664\u5217c\uff09<\/pre>\n<p>&nbsp;<\/p>\n<p>\/\/\u91cd\u547d\u540d\u5217<\/p>\n<pre class=\"lang:default decode:true\">alter table t1 change a b integer; \uff08\u628a\u5217a\u6539\u540d\u4e3ab\uff0c\u6ce8\u610f\u8981\u6307\u5b9a\u5217\u7c7b\u578b\uff09<\/pre>\n<p>&nbsp;<\/p>\n<p>\/\/\u6539\u53d8\u5217\u7684\u7c7b\u578b<\/p>\n<pre class=\"lang:default decode:true\">alter table t1 change b b bigint not null; \uff08\u628a\u5217a\u6539\u540d\u4e3ab\uff0c\u6307\u5b9a\u5217\u7c7b\u578b\u53canull\u5c5e\u6027\uff09\nalter table infos change list list tinyint not null default '0';<\/pre>\n<p>&nbsp;<\/p>\n<div><\/div>\n<p>\/\/\u91cd\u547d\u540d\u8868<\/p>\n<pre class=\"lang:default decode:true\">alter table t1 rename t2;<\/pre>\n<p>&nbsp;<\/p>\n<p>\u52a0\u7d22\u5f15<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt; alter table tablename change depno depno int(5) not null;\nmysql&gt; alter table tablename add index \u7d22\u5f15\u540d (\u5b57\u6bb5\u540d1[\uff0c\u5b57\u6bb5\u540d2 \u2026]);\nmysql&gt; alter table tablename add index emp_name (name);<\/pre>\n<p>&nbsp;<\/p>\n<p>\u52a0\u4e3b\u5173\u952e\u5b57\u7684\u7d22\u5f15<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt; alter table tablename add primary key(id);<\/pre>\n<p>&nbsp;<\/p>\n<p>\u52a0\u552f\u4e00\u9650\u5236\u6761\u4ef6\u7684\u7d22\u5f15<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt; alter table tablename add unique emp_name2(cardnumber);<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5220\u9664\u67d0\u4e2a\u7d22\u5f15<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt;alter table tablename drop index emp_name;<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4fee\u6539\u8868\uff1a<\/p>\n<p>\u589e\u52a0\u5b57\u6bb5\uff1a<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt; ALTER TABLE table_name ADD field_name field_type;<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4fee\u6539\u539f\u5b57\u6bb5\u540d\u79f0\u53ca\u7c7b\u578b\uff1a<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt; ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5220\u9664\u5b57\u6bb5\uff1a<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt; ALTER TABLE table_name DROP field_name;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u603b\u7ed3\u4e00\u4e0b\u5bf9mysql\u8868\u7ed3\u6784\u7684\u4fee\u6539\u64cd\u4f5c\uff0c\u5305\u62ec\u5bf9\u5b57\u6bb5\u53ca\u7d22\u5f15\u7684\u4fee\u6539\u64cd\u4f5c\uff1a \u6dfb\u52a0\u5b57\u6bb5\uff1a alter table `us [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-29","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29"}],"version-history":[{"count":1,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":454,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions\/454"}],"wp:attachment":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}