从数据库表中获取所有信息模式

Get all information schema from Database tables

如何将以下查询限制为 return 仅针对数据库中的表并排除视图?

USE [Database Name] SELECT * FROM INFORMATION_SCHEMA.COLUMNS

加入sys.Tables:

SELECT  c.*
FROM    INFORMATION_SCHEMA.COLUMNS c inner join sys.tables t
        on c.Table_Name = t.name

Microsoft 不鼓励使用 INFORMATION_SCHEMA。如果您不想使用系统视图,可以这样做:

SELECT  * 
FROM    INFORMATION_SCHEMA.COLUMNS AS C
INNER JOIN INFORMATION_SCHEMA.TABLES AS T
        ON  T.TABLE_SCHEMA = C.TABLE_SCHEMA
        AND T.TABLE_NAME = C.TABLE_NAME
WHERE       T.TABLE_TYPE = 'BASE TABLE'