表の詳細情報・DDL文を確認・表示する [MySQL/MariaDB]

MySQL」、「MariaDB」で表の詳細情報とDDL文を確認・表示する「show table status」、

「show create table」を紹介します。

「show table status」、「show create table」はmysqlコマンド固有のSQL文ですので、

この機会にしっかりマスターしましょう。

DBはインストールされている前提ですので、

MariaDB・MySQLのインストール方法は下の記事を参考にしてください。

あわせて読みたい
LinuxへのMariaDBのインストールとデータベース作成 Linux上でMariaDBをインストールする手順とデータベース作成手順を紹介します。 MariaDBとは MySQLを元に作成されてオープンソースデータベース代表的なLinuxのディスト...
目次

show table status:表の詳細情報を確認・表示

表の詳細情報を確認・表示するのは「show table status」を使用します。

show table status ;

以下実行例になります。

以下の例ではmysql実行時に「-E」オプションで垂直表示に設定しています。

MariaDB [test001]> show table status ;
1. row
Name: tab001
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 4
Avg_row_length: 4096
Data_length: 16384
Max_data_length: 0
Index_length: 0
Data_free: 9437184
Auto_increment: NULL
Create_time: 2018-08-12 20:59:13
Update_time: NULL
Check_time: NULL
Collation: utf8_general_ci
Checksum: NULL
Create_options:
Comment:

show table status like ~:対象を絞って表の詳細情報を確認・表示

「like」句を使用することで対象の表を絞って詳細情報を確認・表示することも出来ます。

show table status like 'pattern';

もちろんワイルドカードとして「%」、「_」を使用することができます。

以下実行例になります。

MariaDB [test001]> show table status like 'tab%';
1. row
Name: tab001
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 4
Avg_row_length: 4096
Data_length: 16384
Max_data_length: 0
Index_length: 0
Data_free: 9437184
Auto_increment: NULL
Create_time: 2018-08-12 20:59:13
Update_time: NULL
Check_time: NULL
Collation: utf8_general_ci
Checksum: NULL
Create_options:
Comment:

show create table:表のDDLを確認・表示する

表のDDLを確認・表示するのは「show create table」を使用します。

show create table tab_name;

以下実行例になります。

MariaDB [test001]> show create table tab001;
1. row
Table: tab001
Create Table: CREATE TABLE tab001 (
col01 varchar(10) DEFAULT NULL,
col02 varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

MariaDB & MySQL全機能バイブルposted with ヨメレバ

鈴木啓修/山田奈緒子 技術評論社 2015年01月

Amazon

Kindle

楽天ブックス

7net

honto

e-hon

紀伊國屋書店

よかったらシェアしてね!
  • URLをコピーしました!
目次