java - 获取特定数据库中用户定义表的列表

标签 java sql sybase

我需要列出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* 是数据库的名称。

Tables and Views

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/

相关文章:

java - Swing:非输入文本字段

linux - 分配服务器CPU核心来执行特定调用

sql inner join - 多列而不是行

sql - Oracle中如何根据上一行的计算结果通过CASE语句动态计算?

Oracle PL/SQL 中的 SQL 与列表在哪里?

sql - 如何在 Sybase sql 子查询的结果上正确使用 GROUP BY

java - 从哪里下载 sajdbc4.jar?

java - 将来自 RabbitMQ 的消息转换为字符串/json

java - 来自 gson 的详细异常消息?

java - struts2-archetype-blank 上的 Maven fatal error