MySQL-DDL-表的结构-查询&修改&删除

DDL(表操作)

  • 查询

    • 查询当前数据库所有表:show tables
    • 查询表结构:desc +表名
    • 查询建表语句:show create table + 表名
  • 修改(主要还是通过图形化界面进行操作)

  • 添加字段:alter table 表名 add 字段名 类型(长度)[comment 注释] [约束] 
  • 修改字段类型:alter table 表名 modify 字段名 新数据类型(长度)
  • 修改字段名和字段类型:alter table 表名 change 旧字段名 类型(长度) [comment 注释] [约束]
  • 删除字段:alter table 表名 drop column 字段名
  • 修改表名:rename table 表名 to 新表名
  • 删除

  • 删除表:drop table [ if exists ] 表名
    • 在删除表时,表中的全部语句都会被删除

猜你喜欢

转载自blog.csdn.net/weixin_64939936/article/details/131753469