---建表
CREATE TABLE temp(
id INT
);
----查询表
SELECT * FROM temp_t;
---删表
DROP TABLE temp;
---修改表名
ALTER TABLE temp_tt RENAME temp;
ALTER TABLE temp RENAME TO temp_t;
ALTER TABLE temp RENAME AS temp_tt;
---常用字段
CREATE TABLE temp(
id INT(4),
NAME CHAR(20),
address VARCHAR(20),
degreed DOUBLE(5,2),
money FLOAT,
birthday DATE,
insertTime TIME,
courrentTime DATETIME
);
---添加字段
ALTER TABLE temp ADD COLUMN age INT(2);//标准写法
ALTER TABLE temp ADD age INT(2);//可以这样写
ALTER TABLE temp ADD COLUMN age INT(2) AFTER NAME;
---删除字段
ALTER TABLE temp DROP COLUMN age;
ALTER TABLE temp DROP age;
---修改字段名
ALTER TABLE temp CHANGE COLUMN age age_t INT(4) CHARSET utf8 COLLATE utf8_general_ci NULL;//标准写法
ALTER TABLE temp CHANGE age_t age INT(4);
---修改字段属性
ALTER TABLE temp MODIFY COLUMN age_t INT(6) FIRST;//定义在第一列
ALTER TABLE temp MODIFY COLUMN age_t INT(6) AFTER money;//定义某列与莫列之后
转载于:https://my.oschina.net/craftsdream/blog/534753