六、mysql数据库
2017-05-27 本文已影响19人
迷糊银儿
1.查看当前所有数据库:show databases;
2.新建、删除数据库:create database qfdb;drop database qfdb;
3.使用某个数据库:use qfdb;
4.创建视图:create [or replace]view view_name[(column_list)] as select_statement
create view user_v(id,name,sex) as select id,name,sex from user;
5.查看创建视图的元数据 show create view user_v;
6.修改视图:alter view view_name[(column_list)]as select_statement
7.删除视图:drop view view_name
8.采用select语句将所选择的行直接写入到下个外部文件中去:select column_name into outfile filename
9.使用多条件进行多表查询:select a.username,a.sex,b.salary from userinfo a,usersalary b where a.userid=b.userid and b.salary>2000
10.使用分组排序查询:seletct a.sex,count(*) as count,avg(b.salary) from userinfo a,usersalary b where a.userid=b.userid and b.salary>2000 and b.salary<4000 group by a.sex