一、创建表
-- 创建表test
create table test(
id int not null default 0 primary key,
name varchar(30) not null default '',
age tinyint not null default 0
);
-- 修改表名
rename table test to test1;
二、列的修改
在表tableName中,增加列columnName,类型type,位置在id列后
语法:alter table tableName add columnName type after id;
-- 在test表中的name列后,增加gender列. 没有after,则默认加到表的最后
alter table test add gender tinyint default 1 not null after name;
-- 删除gender列
alter table test drop gender;
-- 修改列名
alter table test change name fullname varchar(30) not null default '';
-- 修改列参数
alter table test modify fullname varchar(40) not null default '';