码迷,mamicode.com
首页 > 数据库 > 详细

MySQL学习笔记——3.表

时间:2014-12-31 21:18:05      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

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
出处:http://www.cnblogs.com/zhnoah/
本文版权归本人和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连 
接,否则保留追究法律责任的权利。

MySQL学习笔记——3.表

标签:

原文地址:http://www.cnblogs.com/zhnoah/p/4196459.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!