end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

mysqlでのテーブル/ビューの判定は、INFORMATION_SCHEMA.TABLESで

http://dev.mysql.com/doc/refman/5.1/en/tables-table.html
↑ここに書いてあるとおりですが、次のsqlで区別できます。

VIEWの場合

SELECT table_name, table_type FROM INFORMATION_SCHEMA.TABLES
  WHERE table_schema = 'test_db' and table_name LIKE 'test_view';
+------------+------------+
| table_name | table_type |
+------------+------------+
| test_view  | VIEW       |
+------------+------------+
1 row in set (0.00 sec)

TABLEの場合

SELECT table_name, table_type FROM INFORMATION_SCHEMA.TABLES
  WHERE table_schema = 'test_db' and table_name LIKE 'test_table';
+------------+------------+
| table_name | table_type |
+------------+------------+
| test_table | BASE TABLE |
+------------+------------+
1 row in set (0.00 sec)

単純にテーブルの存在を確認する場合

以下は、おまけです

show tables like '$table_name'