2php : MySQLのデータの表示(SHOW)

 

SHOW DATABASES

SHOW DATABASES文はすでに存在しているデータベースの一覧を表示します。

mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql    |
| tamayaDB |
| test     |
+----------+
3 rows in set (0.00 sec)

SHOW TABLES

SHOW TABLES文はすでに存在しているテーブルの一覧を表示します。このコマンドはUSE文でデータベースを選択している必要があります。データベースを選択していない場合は、『SHOW TABLES FROM [データベース名]』の様に利用します。

mysql> SHOW TABLES;
+--------------------+
| Tables_in_tamayaDB |
+--------------------+
| comicbeam_shain    |
| testtable          |
| uriage             |
| userinfo           |
+--------------------+
4 rows in set (0.00 sec)

SHOW TABLE STATUS

SHOW TABLE STATUS文は選択したデータベース名の状況を表示します。現在どのテーブルにどれだけのデータ容量があるかも表示されます。このコマンドもUSE文でデータベースを選択していない場合は『SHOW TABLE STATUS FROM [データベース名]』の様に利用します。

mysql> SHOW TABLE STATUS;
+-----------------+--------+------------+------+----------------+-------------+-
----------------+--------------+-----------+----------------+-------------------
--+---------------------+------------+----------------+---------+
| Name            | Type   | Row_format | Rows | Avg_row_length | Data_length |
Max_data_length | Index_length | Data_free | Auto_increment | Create_time
  | Update_time         | Check_time | Create_options | Comment |
+-----------------+--------+------------+------+----------------+-------------+-
----------------+--------------+-----------+----------------+-------------------
--+---------------------+------------+----------------+---------+
| comicbeam_shain | MyISAM | Fixed      |    0 |              0 |           0 |
    30064771071 |         1024 |         0 |           NULL | 2004-08-11 19:41:1
3 | 2004-08-11 19:41:13 | NULL       |                |         |
| testtable       | MyISAM | Fixed      |    0 |              0 |           0 |
    21474836479 |         1024 |         0 |          10000 | 2004-08-11 20:04:1
0 | 2004-08-11 20:04:10 | NULL       |                |         |
| uriage          | MyISAM | Fixed      |    0 |              0 |           0 |
    55834574847 |         1024 |         0 |           NULL | 2004-08-11 17:42:1
4 | 2004-08-11 17:42:14 | NULL       |                |         |
| userinfo        | MyISAM | Dynamic    |    2 |             42 |          84 |
     4294967295 |         2048 |         0 |              3 | 2004-08-13 08:23:4
6 | 2004-08-13 08:34:35 | NULL       |                |         |
+-----------------+--------+------------+------+----------------+-------------+-
----------------+--------------+-----------+----------------+-------------------
--+---------------------+------------+----------------+---------+
4 rows in set (0.00 sec)

SHOW STATUS

SHOW STATUS文は現在のデータベースの状況を表示します。エラーがいくつあったか、現在のアップタイムなどはどのくらいか等の情報を表示します。

mysql> SHOW STATUS;
+--------------------------+---------+
| Variable_name            | Value   |
+--------------------------+---------+
| Aborted_clients          | 0       |
| Aborted_connects         | 3       |
| Bytes_received           | 1716    |
| Bytes_sent               | 3875    |
| Com_admin_commands       | 0       |
| Com_alter_table          | 0       |
| Com_analyze              | 0       |
| Com_backup_table         | 0       |
| Com_begin                | 0       |
| Com_change_db            | 2       |
| Com_change_master        | 0       |
| Com_check                | 0       |
| Com_commit               | 0       |
| Com_create_db            | 1       |
| Com_create_function      | 0       |
| Com_create_index         | 0       |
| Com_create_table         | 4       |
| Com_delete               | 0       |
| Com_drop_db              | 0       |
| Com_drop_function        | 0       |
| Com_drop_index           | 0       |
| Com_drop_table           | 0       |
| Com_flush                | 1       |
| Com_grant                | 1       |
| Com_insert               | 2       |
| Com_insert_select        | 0       |
| Com_kill                 | 0       |
| Com_load                 | 0       |
| Com_load_master_table    | 0       |
| Com_lock_tables          | 0       |
| Com_optimize             | 0       |
| Com_purge                | 0       |
| Com_rename_table         | 0       |
| Com_repair               | 0       |
| Com_replace              | 0       |
| Com_replace_select       | 0       |
| Com_reset                | 0       |
| Com_restore_table        | 0       |
| Com_revoke               | 0       |
| Com_rollback             | 0       |
| Com_select               | 6       |
| Com_set_option           | 2       |
| Com_show_binlogs         | 0       |
| Com_show_create          | 0       |
| Com_show_databases       | 3       |
| Com_show_fields          | 7       |
| Com_show_grants          | 0       |
| Com_show_keys            | 0       |
| Com_show_logs            | 0       |
| Com_show_master_status   | 0       |
| Com_show_open_tables     | 0       |
| Com_show_processlist     | 0       |
| Com_show_slave_status    | 0       |
| Com_show_status          | 1       |
| Com_show_innodb_status   | 0       |
| Com_show_tables          | 4       |
| Com_show_variables       | 0       |
| Com_slave_start          | 0       |
| Com_slave_stop           | 0       |
| Com_truncate             | 0       |
| Com_unlock_tables        | 0       |
| Com_update               | 0       |
| Connections              | 11      |
| Created_tmp_disk_tables  | 0       |
| Created_tmp_tables       | 0       |
| Created_tmp_files        | 0       |
| Delayed_insert_threads   | 0       |
| Delayed_writes           | 0       |
| Delayed_errors           | 0       |
| Flush_commands           | 1       |
| Handler_delete           | 0       |
| Handler_read_first       | 2       |
| Handler_read_key         | 3       |
| Handler_read_next        | 0       |
| Handler_read_prev        | 0       |
| Handler_read_rnd         | 0       |
| Handler_read_rnd_next    | 21      |
| Handler_update           | 1       |
| Handler_write            | 4       |
| Key_blocks_used          | 4       |
| Key_read_requests        | 7       |
| Key_reads                | 3       |
| Key_write_requests       | 5       |
| Key_writes               | 5       |
| Max_used_connections     | 0       |
| Not_flushed_key_blocks   | 0       |
| Not_flushed_delayed_rows | 0       |
| Open_tables              | 4       |
| Open_files               | 8       |
| Open_streams             | 0       |
| Opened_tables            | 19      |
| Questions                | 43      |
| Select_full_join         | 0       |
| Select_full_range_join   | 0       |
| Select_range             | 0       |
| Select_range_check       | 0       |
| Select_scan              | 0       |
| Slave_running            | OFF     |
| Slave_open_temp_tables   | 0       |
| Slow_launch_threads      | 0       |
| Slow_queries             | 0       |
| Sort_merge_passes        | 0       |
| Sort_range               | 0       |
| Sort_rows                | 0       |
| Sort_scan                | 0       |
| Table_locks_immediate    | 19      |
| Table_locks_waited       | 0       |
| Threads_cached           | 0       |
| Threads_created          | 10      |
| Threads_connected        | 1       |
| Threads_running          | 1       |
| Uptime                   | 7405615 |
+--------------------------+---------+
112 rows in set (0.00 sec)