数据表结构的修改

语法:ALTER TABLE 表名 增删改 列名 类型(长度) 约束

现有表A
1. 增加语法 : alter table A add *** ;
例:在表 A 中增加 speedy 列 alter table A add speedy double ;


2. 修改现有的类型 : alter table A modify *** ;
例:修改 name 长度为30 : alter table A modify name vachar(30) not null ;
修改birthday 列不能为空 : alter table A modify birthday not null ;


3. 删除已有列 : alter table A drop 列名 ;
例: 删除列 age :ALTER TABLE A DROP AGE ;


4. 修改现有列名 :alter table A change 旧名 新名 类型 约束 ;


5. 修改表名 :rename table A to B ;


6. 修改表的字符集 : alter table A character set 编码集 ;
例:将表的修改码改为 utf8 :alter table A character set utf8 ;

猜你喜欢

转载自blog.csdn.net/weixin_43072485/article/details/82112825