Open Source WEB

テーブルのリストは、 SHOW TABLES というのがあった。 だから、ビューに対しては、SHOW VIEWS があるに違いない。

mysql> SHOW VIEWS;
ERROR 1064 (42000): You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for
the right syntax to use near 'VIEWS' at line 1
mysql>

勝手な想像をしてしまったようだ。

SHOW TABLES で、ビューもリストアップできるようだ。

mysql> SHOW TABLES;
+----------------+
| Tables_in_test |
+----------------+
| ビュー         |
| 漢字           |
+----------------+
2 rows in set (0.00 sec)

mysql>

しかし、これでは、テーブルなのかビューなのかさっぱり分からなくなるではないか。 人間がいずれでであるかを憶えなければならないのは馬鹿馬鹿しい。 それに、私にはそんな記憶力もない!

ということで、また

13.5.4.19. SHOW TABLES Syntax でちゃんと確認しよう。 残念ながら、日本語マニュアルはない。

SHOW [FULL] TABLES [FROM db_name] [LIKE 'pattern']

SHOW TABLES lists the non-TEMPORARY tables in a given database.
You can also get this list using the mysqlshow db_name command.

Before MySQL 5.0.1, the output from SHOW TABLES contains a single
column of table names. Beginning with MySQL 5.0.1, this command
also lists any views in the database. As of MySQL 5.0.2, the FULL
modifier is supported such that SHOW FULL TABLES displays a second
output column. Values for the second column are BASE TABLE for a
table and VIEW for a view.

要するに、

  • SHOW TABLES で ビュー も見える。
  • SHOW FULL TABLES だと、テーブルとビューを識別できるカラムがつく。

では、さっそく試してみよう。

mysql> SHOW FULL TABLES;
+----------------+------------+
| Tables_in_test | Table_type |
+----------------+------------+
| ビュー         | VIEW       |
| 漢字           | BASE TABLE |
+----------------+------------+
2 rows in set (0.00 sec)

mysql>

戻る:ビューの作成

次へ:ビューのカラム名に漢字を使った場合


フィードバック:

Name:
Comment:

There is no comment.

このサイトは、 IPA の「平成15年度オープンソフトウエア活用基盤整備事業」 の委託事業として開発されたKahuaで試験的に運用しております。

Copyright (c) 2004-2007 株式会社タイムインターメディア About Us