问题描述
是否有一些SQL会返回表名列表,或者(切入正题)会返回一个布尔值,说明是否存在具有特定模式的表名?
Is there some SQL that will either return a list of table names or (to cut to the chase) that would return a boolean as to whether a tablename with a certain pattern exists?
具体来说,我需要知道数据库中是否有名为 INV [Bla]
的表,例如 INVclay
, INVcherri
, INVkelvin
, INVmorgan
, INVgrandFunk
, INVgobbledygook
, INV2468WhoDoWeAppreciate
等( INV
部分正是我要寻找的;表名的其余部分几乎可以是任何东西。)
Specifically, I need to know if there is a table in the database named INV[Bla]
such as INVclay
, INVcherri
, INVkelvin
, INVmorgan
, INVgrandFunk
, INVgobbledygook
, INV2468WhoDoWeAppreciate
, etc. (the INV
part is what I'm looking for; the remainder of the table name could be almost anything).
IOW,可以在SQL语句中使用通配符,例如:
IOW, can "wildcards" be used in a SQL statement, such as:
SELECT * tables
FROM database
WHERE tableName = 'INV*'
或如何实现?
推荐答案
这应该可以帮助您:
SELECT *
FROM INFORMATION_SCHEMA.TABLES
where table_name LIKE '%INV%'
编辑:
固定 table_name
这篇关于如何从SQL Server CE数据库检索所有表名的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!