mysql

1.创建数据库samp_db

create database samp_db character set gbk;

2.插入

insert into students (name, sex, age) values("孙丽华", "女", 21);

3.查询

查询年龄在21岁以上的所有人信息: select * from students where age > 21;

查询名字中带有 "王" 字的所有人信息: select * from students where name like "%王%";

查询id小于5且年龄大于20的所有人信息: select * from students where id<5 and age>20;

4.修改列

将表 tel 列改名为 telp:honealter table students change tel telphone char(13) default "-";

将 name 列的数据类型改为 char(16): alter table students change name name char(16) not null;

5.删除

删除 birthday 列: alter table students drop birthday;

删除 workmates 表: drop table workmates;

删除 samp_db 数据库: drop database samp_db;

6.重命名

重命名 students 表为 workmates: alter table students rename workmates;

posted @ 2016-02-23 14:59  简惬  阅读(155)  评论(0编辑  收藏  举报