(数据库 |
您所在的位置:网站首页 › 数据库修改数据表名 › (数据库 |
对于数据表的修改,我们通常会使用如下操作:添加列(add)、修改列(modify)、修改列名(change)、删除列(drop)、修改表名(rename)、修改表的字符集。 1.添加列(add) alter table 表名 add 列名 列的类型( 列的约束); alter table student add chengji int not null; 2.修改列(modify) alter table 表名 modify 列名 列的类型( 列的约束); alter table student modify sex varchar(2); 3.修改列名(change) alter table 表名 change 列名 新的列名 列的类型( 列的约束); alter table student change sex gender varchar(2); 4.删除列(drop) alter table 表名 drop 列名; alter table student drop chengji; 5.修改表名(rename) rename table 旧表名 to 新的表名 尽量不使用,避免因为修改,引起大量麻烦! 6.修改表的字符集 alter table 表名 character set 字符集 alter table student character set gbk; show create table student; 数据表的修改,主要针对不完善的地方进行操作,尽量不要使用修改表名! |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |