に最終更新
SHOW TABLE STATUS
説明
テーブルまたはビューに関する情報を表示します。
構文
SHOW TABLE STATUS [ FROM [ <catalog_name>.]<db_name> ] [ LIKE <like_condition> ]
任意パラメータ
1. FROM [ <catalog_name>.]<db_name>
FROM 句で照会するカタログ名とデータベース名を指定できます。
2. LIKE <like_condition>
LIKE 句でテーブル名によるあいまい検索ができます。
戻り値
| 列 | データ型 | 説明 |
|---|---|---|
| Name | String | テーブル名 |
| Engine | String | テーブルのストレージエンジン |
| バージョン | String | バージョン |
| Row_format | String | 行形式。MyISAM エンジンでは Dynamic、Fixed、Compressed のいずれかです。Dynamic 行の長さは Varchar 型や Blob 型のフィールドのように可変で、Fixed 行の長さは Char 型や Integer 型のフィールドのように固定です。 |
| Rows | String | テーブルの行数。非トランザクションテーブルでは正確な値で、トランザクションエンジンでは通常は推定値です。 |
| Avg_row_length | Integer | 行あたりの平均バイト数 |
| Data_length | Integer | テーブル全体のデータ量(バイト単位) |
| Max_data_length | Integer | テーブルが保持できるデータ量の上限 |
| Index_length | Integer | インデックスが使用するディスク容量 |
| Data_free | Integer | MyISAM エンジンで割り当て済みだが現在未使用の領域。削除された行の領域も含みます。 |
| Auto_increment | Integer | 次の Auto_increment 値 |
| Create_time | Datetime | テーブルの作成時刻 |
| Update_time | Datetime | テーブルの最終更新時刻 |
| Check_time | Datetime | check table または myisamchk ツールでテーブルを最後に検査した時刻 |
| Collation | String | テーブルのデフォルト文字セット。現在は utf-8 のみをサポートします |
| Checksum | String | 有効な場合、テーブル全体の内容から計算したチェックサム |
| Create_options | String | テーブル作成時に指定したその他のオプション |
| Comment | String | テーブルのコメント |
必要な権限
この SQL コマンドを実行するユーザーには、少なくとも次の権限が必要です。
| 権限 | 対象 | 説明 |
|---|---|---|
| ADMIN_PRIV | Table, View | 現在、この操作を実行できるのは ADMIN 権限を持つユーザーのみです |
使用上の注意
- この文は主に MySQL 構文との互換性のために使用します。現在表示される情報は Comment など一部に限られます。
例
-
現在のデータベースにあるすべてのテーブルの情報を表示します
SHOW TABLE STATUS+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------+----------+----------------+---------+
| test_table | Doris | NULL | NULL | 0 | 0 | 0 | NULL | NULL | NULL | NULL | 2025-01-22 11:45:36 | 2025-01-22 11:45:36 | NULL | utf-8 | NULL | NULL | |
| test_view | View | NULL | NULL | 0 | 0 | 0 | NULL | NULL | NULL | NULL | 2025-01-22 11:46:32 | NULL | NULL | utf-8 | NULL | NULL | |
+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------+----------+----------------+---------+ -
指定したデータベース内で名前に example を含むテーブルの情報を表示します
SHOW TABLE STATUS FROM db LIKE "%test%"+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------+----------+----------------+---------+
| test_table | Doris | NULL | NULL | 0 | 0 | 0 | NULL | NULL | NULL | NULL | 2025-01-22 11:45:36 | 2025-01-22 11:45:36 | NULL | utf-8 | NULL | NULL | |
| test_view | View | NULL | NULL | 0 | 0 | 0 | NULL | NULL | NULL | NULL | 2025-01-22 11:46:32 | NULL | NULL | utf-8 | NULL | NULL | |
+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------+----------+----------------+---------+