如何编写以仅返回列名为'employee_no'
的DB中存在的表,以便我可以说
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME like '%employee_no'
但这也会返回视图,我只想要实际的表格。
之类的东西?
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME like '%employee_no' and WHERE TYPE = 'U'
答案 0 :(得分:3)
您可以查看TABLES.TABLE_TYPE
:
SELECT c.*
FROM INFORMATION_SCHEMA.COLUMNS c JOIN
INFORMATION_SCHEMA.TABLES t
ON c.table_name = t.table_name AND
c.table_schema = t.table_schema
WHERE c.COLUMN_NAME like '%employee_no' AND
t.table_type = 'BASE TABLE';