我需要列出sybase中特定数据库中所有表的名称,然后根据名称中的某些字符串过滤这些表名称。
这给出了当前数据库,但我无法指定特定数据库:
select name from sysobjects where type = 'U'
这提供的不仅仅是表,还包括触发器和存储过程:
Select name from sysobjects
WHERE db_name()='pad_orr_db'
是否有人知道如何执行此操作,并通过名称中的某些字符串过滤表的名称,例如仅显示名称中带有 SASSA 的表?
最佳答案
使用sp_tables 。
sp_tables [table_name] [, table_owner]
[, table_qualifier][, table_type]
其中 *table_qualifier* 是数据库的名称。
To get all tables, views, and system tables, the following Sybase system stored procedure can be executed.
exec sp_tables '%'
To filter by database for tables only, for example master:
exec sp_tables '%', '%', 'master', "'TABLE'"
To filter by database and owner / schema for tables only, for example, master and dbo:
exec sp_tables '%', 'dbo', 'master', "'TABLE'"
To return only views, replace "'TABLE'" with "'VIEW'". To return only system tables, replace "'TABLE'" with "'SYSTEM TABLE'".
关于java - 获取特定数据库中用户定义表的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18528120/