首页 > 数据库技术 > 详细

MySQL--数据表操作

时间:2017-09-06 22:44:41      阅读:254      评论:0      收藏:0      [点我收藏+]
| 表的创建
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--数据表操作

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!