如何在當前使用的資料庫中檢查 MySQL 表的列表,並在結果集中包含表型別?


可以使用 SHOW FULL TABLES 語句實現。其語法如下:

語法

SHOW FULL TABLES

示例

在以下示例中,我們當前的資料庫是“query”,因此下面的語句將顯示來自該資料庫的表列表以及結果集中的表型別:

mysql> SHOW FULL TABLES;
+-----------------------------+------------+
| Tables_in_query             | Table_type |
+-----------------------------+------------+
| accounts                    | BASE TABLE |
| address                     | BASE TABLE |
| cars                        | BASE TABLE |
| cars_avgprice               | VIEW       |
| countries                   | BASE TABLE |
| customer_view               | VIEW       |
| customers                   | BASE TABLE |
| date_time_test              | BASE TABLE |
| detail_bday                 | BASE TABLE |
| details_city                | BASE TABLE |
.
.
.
| view_student_detail         | VIEW       |
| view_student_detail_columns | VIEW       |
| websites                    | BASE TABLE |
+-----------------------------+------------+
87 rows in set (0.01 sec)

以上結果集顯示了表以及表型別,即它是 BASE TABLE 還是 VIEW。

更新於:2020-06-20

72 次瀏覽

啟動你的 職業生涯

透過完成課程獲得認證

開始學習
廣告