94
79

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MySQLで全テーブルのレコード数を一覧表示する

Last updated at Posted at 2017-04-28

はじめに

とりあえずMySQLで各テーブルのレコード数だけサクッと確認したい時ってありませんか?
レプリケーションやリストアの確認の時とかに便利だと思います。

全DBの全テーブル

mysql> select table_name, table_rows from information_schema.TABLES;

DBごと

mysql> select table_name, table_rows from information_schema.TABLES where table_schema = 'DB名';

使用例

mysql> select table_name, table_rows from information_schema.TABLES where table_schema = 'zabbix';
+----------------------------+------------+
| table_name                 | table_rows |
+----------------------------+------------+
| acknowledges               |         15 |
| actions                    |         33 |
| alerts                     |       4104 |
| application_discovery      |          0 |
| application_prototype      |          0 |
| application_template       |       1109 |
| applications               |       1669 |
| auditlog                   |       9649 |
| auditlog_details           |       5326 |
| autoreg_host               |        149 |
| conditions                 |        105 |
| config                     |          1 |
| dbversion                  |          1 |
| dchecks                    |          1 |
| dhosts                     |          0 |
| drules                     |          1 |
| dservices                  |          0 |
| escalations                |         35 |
| events                     |      76184 |
| expressions                |          9 |
| functions                  |       3457 |
| globalmacro                |          1 |
| globalvars                 |          0 |
| graph_discovery            |       1320 |
| graph_theme                |          2 |
| graphs                     |       3207 |
| graphs_items               |       7340 |
| group_discovery            |          0 |
| group_prototype            |          5 |
| groups                     |         31 |
| history                    |   51193976 |
| history_log                |         73 |
| history_str                |    1677118 |
| history_text               |          0 |
| history_uint               |   66853366 |
| host_discovery             |          2 |
| host_inventory             |          0 |
| hostmacro                  |        130 |
| hosts                      |        200 |
| hosts_groups               |        285 |
| hosts_templates            |        242 |
| housekeeper                |          0 |
| httpstep                   |          0 |
| httpstepitem               |          0 |
| httptest                   |          0 |
| httptestitem               |          0 |
| icon_map                   |          0 |
| icon_mapping               |          0 |
| ids                        |         49 |
| images                     |        249 |
| interface                  |        124 |
| interface_discovery        |          0 |
| item_application_prototype |          0 |
| item_condition             |        392 |
| item_discovery             |       4751 |
| items                      |      13054 |
| items_applications         |      13829 |
| maintenances               |          4 |
| maintenances_groups        |          2 |
| maintenances_hosts         |         12 |
| maintenances_windows       |          6 |
| mappings                   |        143 |
| media                      |          8 |
| media_type                 |          3 |
| opcommand                  |          4 |
| opcommand_grp              |          2 |
| opcommand_hst              |          2 |
| opconditions               |          0 |
| operations                 |         40 |
| opgroup                    |          2 |
| opinventory                |          0 |
| opmessage                  |         24 |
| opmessage_grp              |          7 |
| opmessage_usr              |         19 |
| optemplate                 |          7 |
| profiles                   |       5178 |
| proxy_autoreg_host         |          0 |
| proxy_dhistory             |          0 |
| proxy_history              |          0 |
| regexps                    |          7 |
| rights                     |         56 |
| screen_user                |          0 |
| screen_usrgrp              |          0 |
| screens                    |         19 |
| screens_items              |         64 |
| scripts                    |          4 |
| service_alarms             |          0 |
| services                   |          0 |
| services_links             |          0 |
| services_times             |          0 |
| sessions                   |       4599 |
| slides                     |          0 |
| slideshow_user             |          0 |
| slideshow_usrgrp           |          0 |
| slideshows                 |          0 |
| sysmap_element_url         |          1 |
| sysmap_url                 |          0 |
| sysmap_user                |          0 |
| sysmap_usrgrp              |          0 |
| sysmaps                    |          2 |
| sysmaps_elements           |          4 |
| sysmaps_link_triggers      |          0 |
| sysmaps_links              |          0 |
| timeperiods                |          6 |
| trends                     |   13463849 |
| trends_uint                |   17662329 |
| trigger_depends            |         45 |
| trigger_discovery          |        662 |
| triggers                   |       3181 |
| users                      |         10 |
| users_groups               |         10 |
| usrgrp                     |          5 |
| valuemaps                  |         17 |
+----------------------------+------------+
94
79
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
94
79

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?