mysql内如何查询表的个数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql内如何查询表的个数相关的知识,希望对你有一定的参考价值。

mysql中如何查询数据库中有多少个表

参考技术A select count(*) from sysobjects where type ='s'试试这个。。。。。。 参考技术B mysql> SELECT table_name, table_type, engine
-> FROM information_schema.tables
-> WHERE table_schema = 'test'
-> ORDER BY table_name DESC;
-> //
+--------------------+------------+--------+
| table_name | table_type | engine |
+--------------------+------------+--------+
| v_sale_report_x | VIEW | NULL |
| v_sale_report | VIEW | NULL |
| union_tab_2 | BASE TABLE | InnoDB |
| union_tab_1 | BASE TABLE | InnoDB |
| test_trigger_table | BASE TABLE | InnoDB |
| test_tab2 | BASE TABLE | InnoDB |
| test_tab | BASE TABLE | InnoDB |
| test_main | BASE TABLE | InnoDB |
| test_dysql | BASE TABLE | InnoDB |
| test_create_tab4 | BASE TABLE | InnoDB |
| test_create_tab2 | BASE TABLE | InnoDB |
| test_create_tab1 | BASE TABLE | InnoDB |
| test_create_tab | BASE TABLE | InnoDB |
| sale_report | BASE TABLE | InnoDB |
| log_table | BASE TABLE | InnoDB |
+--------------------+------------+--------+
15 rows in set (0.02 sec)

注:
上面的 WHERE table_schema = 'test' , 那个 test 是数据库名.
参考技术C 这个写一个程序吧!用 show tables 然后把返回的值统计下! 参考技术D select*form 表名 第5个回答  2013-03-28 show tables;

mysql 数据操作 单表查询 having 过滤 练习

 

 

1. 查询各岗位内包含的员工个数小于2的岗位名、岗位内包含员工名字、个数
mysql> select post,group_concat(name),count(id) from employee group by post;
+-----------+-------------------------------------------------+-----------+
| post      | group_concat(name)                              | count(id) |
+-----------+-------------------------------------------------+-----------+
| operation | 程咬铁,程咬铜,程咬银,程咬金,张野                |         5 |
| sale      | 格格,星星,丁丁,丫丫,歪歪                        |         5 |
| teacher   | 成龙,jinxin,jingliyang,liwenzhou,yuanhao,alex   |         6 |
+-----------+-------------------------------------------------+-----------+
3 rows in set (0.00 sec)

mysql> select post,group_concat(name),count(id) from employee group by post having count(id) <2 ;
Empty set (0.05 sec)

 


3. 查询各岗位平均薪资大于10000的岗位名、平均工资
mysql> select post,avg(salary) from employee group by post having avg(salary) > 10000;
+-----------+---------------+
| post      | avg(salary)   |
+-----------+---------------+
| operation |  16800.026000 |
| teacher   | 175766.718333 |
+-----------+---------------+
2 rows in set (0.04 sec)

 


4. 查询各岗位平均薪资大于10000且小于20000的岗位名、平均工资
mysql> select post,avg(salary) from employee group by post having avg(salary) between 10000 and 20000;
+-----------+--------------+
| post      | avg(salary)  |
+-----------+--------------+
| operation | 16800.026000 |
+-----------+--------------+
1 row in set (0.00 sec)

 

 

 






以上是关于mysql内如何查询表的个数的主要内容,如果未能解决你的问题,请参考以下文章

Mysql数据库一个字段内多个值如何统计个数

MYSQL列中的数据以逗号隔开,如何查询?

请问,在mysql中如何查询每天固定时间段内的数据??

mysql语句:如何写查询当前一小时内的数据

在mysql中如何查询每天固定时间段内的数据?

在mysql中如何查询每天固定时间段内的数据?