若表中有数据最好先备份,注意转换前后的字符长度、以及是否可以互相转换等问题。
ALTER TABLE visitor MODIFY nam VARCHAR(30) Eg: alter table goods modify name varchar(20);//出现字符类型的错误
将参数latin1都修改为utf8 或者直接alter table convert to charset gbk或utf8;
alter table goods add price INT; alter table goods drop price;
alter table student modify sex int after name;
Eg:alter table student change phonenumber phone varchar(20);
Eg: create table studentcopy select * from student;
复制表的列构造 create table studentcopybody like student;
数据的复制(从其他表复制部分列的数据)
Eg: insert into studentcopybody(ID,goodsID) select ID,classname from classname;
Eg: drop table studentcopy,studentcopy2;