您的位置:首页 > 博客中心 > 数据库 >

MySQL学习笔记——3.表

时间:2022-03-14 04:29

1.创建表

  create table 表名 (
  id int unsigned not null auto_increment primary key,
  字段 列类型 not null default ‘‘,
  ……
  字段 列类型 not null default ‘‘
  ) engine myisam charset utf8;

2.修改表

  增加列:

    alter table 表名 add 列名称 列类型 列参数; //在表的最后面增加列

    alter table 表名 add 列名称 列类型 列参数 first; //在表的最前面增加列

    alter table 表名 add 列名称 列类型 列参数 after 某列名称; //在指定的列后面增加列

  删除列:

    alter table 表名 drop 列名称;

  修改列:

    alter table 表名 modify 列名称 新列类型 新列参数; //不能改动列名称

    alter table 表名 change 旧列名称 新列名称 新列类型 新列参数;

 

作者:@zhnoah
出处:
本文版权归本人和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连 
接,否则保留追究法律责任的权利。

热门排行

今日推荐

热门手游