首頁 >資料庫 >mysql教程 >MySQL表的维护和改造_MySQL

MySQL表的维护和改造_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-01 13:38:26947瀏覽

bitsCN.com

MySQL表的维护和改造

 

改变列的数据类型    

[sql] 

ALTER TABLE visitor MODIFY nam VARCHAR(30);  

 

追加新列

[sql] 

ALTER TABLE visitor ADD age INT;  

ALTER TABLE visitor ADD age INT FIRST;  

ALTER TABLE visitor ADD age INT AFTER nam;  

 

改变列的位置

[sql] 

ALTER TABLE visitor MODIFY age INT AFTER nam;  

 

改变列名 和 类型

[sql] 

ALTER TABLE visitor CHANGE birth birthday DATE;  

 

删除列

[sql] 

ALTER TABLE visitor DROP age;  

 

表的复制

[sql] 

CREATE TABLE customerH SELECT * FROM customer;  

CREATE TABLE customerG LIKE customer;  

INSERT INTO customerG SELECT * FROM customer;  

INSERT INTO tb1G(no) SELECT bang FROM tb1;  

 

表的删除

[sql] 

DROP TABLE IF EXISTS customerG;  

DROP TABLE customerG;  

 

bitsCN.com
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn