查看表结构

desc 表名

 MySQL数据表基本操作

show create table 表名\G;  查看表详细结构

 MySQL数据表基本操作

 

修改数据表

修改表名

alter table 旧表名 rename [to] 新表名;     to带不带均可

 MySQL数据表基本操作

 MySQL数据表基本操作

 MySQL数据表基本操作

修改字段的数据类型

alter table 表名 modify 字段名 数据类型;

 MySQL数据表基本操作

MySQL数据表基本操作

添加字段

alter table 表名 add 新字段名 类型 约束条件  [ first | after 已存在字段名];

 MySQL数据表基本操作

删除字段

alter table 表名 drop 字段名;

 MySQL数据表基本操作

修改字段的排列位置

alter table 表名 modify 字段名 字段类型 [ first | after 字段名]

MySQL数据表基本操作

 

更改表的存储引擎

 alter table 表名 engine=更改后的引擎名 ;

 MySQL数据表基本操作

删除外键

 alter table 表名 drop foreign key 外键名; MyISAM存储引擎不支持外键

MySQL数据表基本操作 

 MySQL数据表基本操作

MySQL数据表基本操作

 删除数据表

drop table if exists 1,表2.....n; 删除未被外键关联的表

 MySQL数据表基本操作

如果表是被外键关联的主表则需要先删除外键再删除主表

 MySQL数据表基本操作

MySQL数据表基本操作

MySQL数据表基本操作

 


相关文章:

  • 2022-03-09
  • 2021-06-25
  • 2021-11-26
  • 2021-04-02
  • 2021-09-17
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-26
  • 2021-06-30
  • 2021-10-01
  • 2021-11-06
  • 2021-06-25
  • 2021-12-11
相关资源
相似解决方案