一、修改表名:
1:alter table `old_table` rename to `new_table`;
2:rename table `old_table` to `new_table`;
二、修改列的相关操作:
简单来说表创建完后一些更改表结构的操作都会是
alter table `table_name` operation[add,drop,change,modify,rename];
添加新列标准写法:alter table `table_name` add column `column_name` [other description];
添加新列简写法:alter table `table_name` add `column_name` [other description];
删除列标准写法:alter table `table_name` drop column `cloumn_name`;
删除列列简写法:alter table `table_name` drop `cloumn_name`;
重命名列名/修改列属性:
alter table `table_name` change column `old_column` `new_column` [other description];
alter table `table_name` change `old_column` `new_column` [other description];
修改列属性:
alter table `table_name` modify column `column_name` [other description];
alter table `table_name` modify `column_name` [other description];
change 和 modify都可以重新定义现有列的属性,change的功能更强大些,但必须有`old_column` `new_column`,即便你不想重命名你也得写上一样的,modify则是对现有的列属性进行修改。