close
找出資料庫裡所有的資料表
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
ORDER BY TABLE_NAME
依資料表名稱找出所有欄位資訊
SELECT COLUMN_NAME
,ORDINAL_POSITION,DATA_TYPE
,CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Table1'
依資料表名稱找出此表的PK欄位
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = 'Table1'
全站熱搜