在 MySQL 中顯示錶格的所有欄位?
要顯示所有欄位,請使用以下語法將資料庫設定為 table_schema,將特定表設定為 table_name −
select column_name as anyAliasName from information_schema.columns where table_schema=database() and table_name=’yourTableName’\G
我們先建立一個表 −
mysql> create table DemoTable1938 ( StudentId int, StudentName varchar(20), StudentAge int, StudentCountryName varchar(20), StudentMobileNumber bigint ); Query OK, 0 rows affected (0.00 sec)
以下是顯示錶中所有欄位的查詢 −
mysql> select column_name as ALL_FIELDS from information_schema.columns where table_schema=database() and table_name='DemoTable1938'\G
這將產生以下輸出 −
*************************** 1. row *************************** ALL_FIELDS: StudentId *************************** 2. row *************************** ALL_FIELDS: StudentName *************************** 3. row *************************** ALL_FIELDS: StudentAge *************************** 4. row *************************** ALL_FIELDS: StudentCountryName *************************** 5. row *************************** ALL_FIELDS: StudentMobileNumber 5 rows in set (0.00 sec)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP