修改字段

类型、名、注释、类型长度、默认值

ALTER  TABLE 表名 MODIFY [COLUMN] 字段名 新类型 新类型长度  新默认值  新注释;
-- COLUMN关键字可以省略不写
 
-- 能修改字段类型、类型长度、默认值、注释 
alter  table table1 modify  column column1  decimal(10,1) 
	DEFAULT NULL COMMENT '注释'; 

-- 能修改字段类型、类型长度、默认值、注释 
alter  table table1 modify column1  decimal(10,2) 
	DEFAULT NULL COMMENT '注释'; 

修改字段名

-- 字段名称未改变,修改字段类型、类型长度、默认值、注释
ALTER  TABLE 表名 CHANGE [column] 旧字段名 新字段名 新数据类型;	 
alter  table table1 change column1 column1 varchar(100) DEFAULT 1.2 COMMENT '注释';
-- 修改字段名、字段类型、类型长度、默认值、注释
alter  table table1 change column1 column2 decimal(10,1) DEFAULT NULL COMMENT '注释' 

-- 正常,能修改字段名、字段类型、类型长度、默认值、注释
alter  table table1 change column2 column1 decimal(10,1) DEFAULT NULL COMMENT '注释'
alter  table table1 change column1 column2; -- 报错 
 
mysql> alter table white_user change column name nick_name  varchar(50) null comment '昵称'; -- 正确
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
更改表名

Table 从 db_a 要搬到 db_b

RENAME TABLE db_a.old_table TO db_b.new_table;

MySQL Table 改名字(重命名)

RENAME TABLE old_table TO new_table;

MySQL 两个 Table 互换名

RENAME TABLE old_table TO tmp_table,
new_table TO old_table,
tmp_table TO new_table;
其实

最简单的,打开 IDEA
MySQL修改字段名、修改字段类型_MySQL
直接GUI修改!