#navi(../)
* テーブルのストレージエンジン一覧を表示する方法 [#ed577866]
テーブルごとに指定できるストレージエンジンの一覧を表示する方法を記します。

#contents
#htmlinsertpcsp(db-top.html,db-sp.html)

* 関連資料 [#f0b7e92d]
-[[ストレージエンジンを指定してテーブルを作成する>MySQL/ストレージエンジンを指定してテーブルを作成する]]
-[[デフォルトのストレージエンジンをInnoDBにする方法>MySQL/デフォルトのストレージエンジンをInnoDBにする方法]]

* show table statusで一覧を表示する [#ef804468]
show table statusでストレージエンジン一覧を表示することができます。~
以下にデータベースを作成しInnoDB, MyISAMのテーブルを1つずつ、合計2テーブルを作成しshow table statusコマンドを使用した結果を記します。
** データベースとテーブルを作成 [#ma4c983c]
 $ mysql -u root -p -s
 Enter password: 
 mysql> create database db1;
 mysql> use db1
 mysql> create table t1 (a int, b int) engine innodb;
 mysql> create table t2 (a int, b int) engine myisam;

** show table statusを使用 [#xda94b6f]
 mysql> use db1
 mysql> 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
 t1      InnoDB  10      Compact 0       0       16384   0       0       4194304 NULL    2012-10-01 16:57:19   NULL    NULL    utf8_general_ci NULL
 t2      MyISAM  10      Fixed   0       0       0       2533274790395903        1024    0       NULL 2012-10-01 16:57:27      2012-10-01 16:57:27     NULL    utf8_general_ci NULL
テーブルの各種情報が表示されEngineの部分を見ればストレージエンジンを特定することができます。~
しかしこれでは見にくいので\Gを使用して縦表示にしてみます。

** show table status \G を使用 [#aad0d6fc]
縦に表示(\G)により少し見やすくなりました。
 mysql> show table status \G
 *************************** 1. row ***************************
            Name: t1
          Engine: InnoDB
         Version: 10
      Row_format: Compact
            Rows: 0
  Avg_row_length: 0
     Data_length: 16384
 Max_data_length: 0
    Index_length: 0
       Data_free: 4194304
  Auto_increment: NULL
     Create_time: 2012-10-01 16:57:19
     Update_time: NULL
      Check_time: NULL
       Collation: utf8_general_ci
        Checksum: NULL
  Create_options: 
         Comment: 
 *************************** 2. row ***************************
            Name: t2
          Engine: MyISAM
         Version: 10
      Row_format: Fixed
            Rows: 0
  Avg_row_length: 0
     Data_length: 0
 Max_data_length: 2533274790395903
    Index_length: 1024
       Data_free: 0
  Auto_increment: NULL
     Create_time: 2012-10-01 16:57:27
     Update_time: 2012-10-01 16:57:27
      Check_time: NULL
       Collation: utf8_general_ci
        Checksum: NULL
  Create_options: 
         Comment: 

* SELECTを使ってinformation_schemaから情報をストレージエンジン情報を取得する [#ffc2a08c]
この方法がストレージエンジンを調べるときに一番見やすいと思います。~
- 構文
 select table_name, engine from  information_schema.tables where table_schema = 'データベース名';
- 実行結果
 mysql> select table_name, engine from  information_schema.tables where table_schema = 'db1';
 +------------+--------+
 | table_name | engine |
 +------------+--------+
 | t1         | InnoDB |
 | t2         | MyISAM |
 +------------+--------+
 2 rows in set (0.00 sec)

#htmlinsertpcsp(db-btm.html,db-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS