如何在没有时间戳列的情况下获取数据库中的表列表?
有什么建议吗?
答案 0 :(得分:5)
使用INFORMATION SCHEMA次观看次数:
select * from INFORMATION_SCHEMA.TABLES T where NOT EXISTS
(
select 1
from INFORMATION_SCHEMA.COLUMNS
where TABLE_CATALOG = T.TABLE_CATALOG
and TABLE_SCHEMA = T.TABLE_SCHEMA
and TABLE_NAME = T.TABLE_NAME
and DATA_TYPE = 'timestamp' -- or the literal representing timestamp data type
)
答案 1 :(得分:3)
使用SYS.TABLES / SYS.COLUMNS:
SELECT name FROM SYS.TABLES
WHERE object_id NOT IN (select object_id
FROM SYS.COLUMNS
WHERE system_type_id = 189)
答案 2 :(得分:0)
您可以使用OBJECTPROPERTY
SELECT
name
FROM
sys.objects
WHERE
OBJECTPROPERTY(object_id, 'TableHasTimestamp') = 0 --null if not a table