MySQL增删改查之——查(普通查询)

show 的用法

1:查询数据库,查询表的详细信息

show create database;      show create table;

2:查看字符集

show variables like '%var%';

3:查看校对规则

show variables like '%collation%';

4、显示一个用户的权限

show grants for user_name@localhost; 

5、显示表的索引

show index from [index_name]

6、显示一些系统特定资源的信息,例如,正在运行的线程数量

show status

7、显示系统中正在运行的所有进程,也就是当前正在执行的查询。大多数用户可以查看他们自己的进程,但是如果他们拥有process权限,就可以查看所有人的进程,包括密码。

show processlist

8、 显示服务器所支持的不同权限

show privileges; 

9、显示安装以后可用的存储引擎和默认引擎。

show engies;

10、显示innoDB存储引擎的状态

show innodb status;

11、显示BDB存储引擎的日志

show logs;

select的用法

1、select concat(first_namem,’ ‘,last_name) as name,concat(city,’,’,state) as birth placefrom president;

2、select * from stu where mid(name,2,1) = "三";    //查询名字从第二个开始的1个字符是“三”的学生   left(name,2) 左边前面两个 right(name,2)右边后两个字

3、select distinct state from president  //看看美国总统们都来自那些州?(重复的不计)

4、select count(*) from student where sex=2     // 统计班上性别是女的学生有多少

5、select sex,count(*) as count from student group by sex    //统计班上男女学生各有多少

6、select state,count(*) as count from president group by state order by count desc limit 4; //看看出生总统最多的前四个州是哪几个?

原文地址:https://www.cnblogs.com/xuxiang/p/3063290.html