2009-08-04 91 views

回答

4
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT 
    FROM INFORMATION_SCHEMA.COLUMNS 
WHERE column_name LIKE '%watcher%' 
[AND table_schema = 'database'] 
+0

我在殼上運行時遇到錯誤。 也許我輸錯了?我們可以使用SELECT TABLE_NAME,COLUMN_NAME,DATA_TYPE,IS_NULLABLE,COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name LIKE'%watcher%'[AND table_schema ='database']; 錯誤1064(42000):您的SQL語法錯誤;請檢查與您的MySQL服務器版本相對應的手冊,以找到在第1行'[AND table_schema ='database']'附近使用的正確語法。 – 2009-08-04 20:29:26

1

這說明你更多的信息.​​..

DECLARE @columnName as varchar(100) 
SET @columnName = 'ColumnName' 

SELECT t.name AS Table, c.name AS Column, 
ty.name AS Type, c.max_length AS Length, c.precision AS Precision 
FROM sys.tables AS t 
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID 
INNER JOIN sys.types ty ON c.system_type_id = ty.system_type_id 
WHERE c.name LIKE @columnName 
ORDER BY t.name, c.name 

希望它能幫助!

相關問題