SQL 查看資料表的欄位與類型
本次環境使用的是MySQL5.7版
1.查看資料表的欄位與類型
SELECT COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tableName';
1.查看資料表的欄位與類型
SELECT COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tableName';
mysql> SELECT COLUMN_NAME, DATA_TYPE
-> FROM INFORMATION_SCHEMA.COLUMNS
-> WHERE TABLE_NAME = 'Persons_copy';
+-------------+-----------+
| COLUMN_NAME | DATA_TYPE |
+-------------+-----------+
| PersonID | int |
| LastName | varchar |
| FirstName | varchar |
| Address | varchar |
| City | varchar |
+-------------+-----------+
5 rows in set (0.00 sec)
留言
張貼留言