如何在當前使用的資料庫中檢視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)

上述結果集顯示了表以及表型別,即它是基本表還是檢視。

更新於:2020年6月20日

72 次瀏覽

啟動您的職業生涯

完成課程獲得認證

開始學習
廣告