MySQL中表的列结构的修改操作

首先创建一个用于测试的表test_table

drop table if exists test_table;
CREATE TABLE `test_table` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(20) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  `brief` varchar(100) DEFAULT NULL
);

在表的最后插入一列:

alter table test_table add column test_column1 varchar(20);

在表的某一列后插入一列:

alter table test_table add column test_column2 varchar(20) after name;

在表的开头插入一列:

alter table test_table add column test_column3 varchar(20) first;

删除某一列:

alter table test_table drop column test_column1;

修改某一列的类型:

alter table test_table modify column test_column2 integer;
原文地址:https://www.cnblogs.com/zifeiy/p/9998995.html