MySQL中的修改表操作

一.增加表的列

 语法:alter table 表名 add(

          增加列定义

         );

 实例:

#增加列 
alter table text add(
   text_num int not null default 0
);

 

 二.修改列的类型

语法:alter table 表名 modify 列名 类型;

 实例:

alter table text modify text_num int;

 

 三.修改列名

 语法:alter table 表名 change  原列名   新列名   新的列类型;

 实例:

alter table text change text_num text_num1 varchar(10);

 

 四.删除列

语法:alter table 表名 drop 列名

实例:

alter table text drop text_num1;

五.修改表名

语法:alter table 表名 rename to 新表名;

实例:

alter table text rename to text1;

 

posted on 2018-09-14 16:17  真正的小明被占用了  阅读(114)  评论(0编辑  收藏  举报

导航