Exclude Views in INFORMATION_SCHEMA

xster
xster
Published in
1 min readJul 16, 2009

Another quick tip.
Selecting from INFORMATION_SCHEMA.COLUMNS unfortunately returns also every column in views on top of tables. I never use views and definitely don’t need those columns.

To filter them out, use:

SELECT * from INFORMATION_SCHEMA.COLUMNS c
JOING INFORMATION.TABLES t ON c.TABLE_NAME = t.TABLE_NAME
AND t.TABLE_TYPE = 'BASE TABLE'

--

--