mysql基础语句(2)

  1. 修改表名(一):alter table 表名 rename [to | as] 新表名 修改表名(二):
  2. alter table 表名 to 新表名

字段

  1. 新增字段:alter table 表名 add 字段名称 字段类型 [约束条件] [after | first 字段名]
  • [after | first 字段名 ] :位置
  1. 删除字段名:alter table 表名 drop [column] 字段名
  2. 修改类型(一):alter table 表名 modify 字段名 字段类型 [约束条件] [after | first 字段名]
  3. 修改类型(二):alter table 表名 change 原字段名 字段名 字段类型 [约束条件] [after | first 字段名]
  4. 添加主键:alter table 表名 add primary key(字段名)
  5. 删除主键:alter table 表名 drop primary key
  6. 添加唯一约束:alter table 表名 unique(字段名)
  7. 删除唯一约束:alter table 表名 drop index 索引
  8. 添加默认值:alter table 表名 alter 字段名称 set default ‘‘默认值’’
  9. 删除默认值:alter table 表名 alter 字段名称 drop default
  10. 修改自增长:alter table 表名 aotu_increment = 新开始
  11. 修改表名(一):alter table 表名 rename [to | as] 新表名
  12. 修改表名(二):alter table 表名 to 新表名

记录

1.新增记录(一): insert into 表名(字段名1,字段名2) values (值1 | default,值2)
2.新增记录(二):update 表名 字段名称 set 值

猜你喜欢

转载自blog.csdn.net/weixin_45936162/article/details/105800068