一、創建表
-- 創建表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 '';