Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以使用什么 SQL 查询来检查表是否存在。
我需要支持不同版本的架构,有些部署可能会遗漏某些表
如果它们是缓存表,您可以使用%Dictionary.CompiledClass系统表。
%Dictionary.CompiledClass
select id from %Dictionary.CompiledClass where SqlSchemaName='%BI' and SqlTableName='Alerts'
或者,如果您知道表的缓存类名称,
select id from %Dictionary.CompiledClass where ID='%BI.Alerts'
如果表 %BI.Alerts 存在,这些查询将返回 1 行。