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

MySQL--数据表操作

时间:2017-09-06 23:01:23      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:mysql--数据表操作

| 表的创建
create table 表名(字段名 类型名 约束)
# create table students(
    id int unsigned primary key auto_increment not null,
    name varchar(20) default ‘‘,
    age tinyint unsigned default 0,
    height decimal(5,2),
    gender enum(‘男‘,‘女‘,‘人妖‘,‘保密‘),
    cls_id int unsigned default 0
);
# create table classes(
    id int unsigned auto_increment primary key not null,
    name varchar(10)
);
 | 查看数据库中所有表
show tables;
| 查看创建语句
show create table classes;
| 查看表结构,描述表
desc classes; 
- 修改字段
| 修改表-添加字段 add
alter table students add birthday datetime;
| 修改表-修改字段:不重命名版 modify
alter table students modify birthday date;
| 修改表-修改字段:重命名版 change
alter table students change birthday birth date;
| 修改表-删除字段 drop
alter table students drop high;
| 删除表
drop table students;

MySQL--数据表操作

标签:mysql--数据表操作

原文地址:http://13269293.blog.51cto.com/13259293/1963243

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