有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在sybase中获取特定数据库中的用户定义表列表

我需要在sybase中列出特定数据库中所有表的名称,然后根据名称中的某个字符串筛选这些表名称

这提供了当前数据库,但我无法指定具体的数据库

select name from sysobjects where type = 'U'

这提供了不止一个表,它包括触发器和存储过程

Select name from sysobjects
WHERE db_name()='pad_orr_db'

是否有任何主体知道如何执行此操作,并通过名称中的某个字符串过滤表名?例如,仅显示名称中带有SASSA的表


共 (3) 个答案

  1. # 1 楼答案

    使用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'".

  2. # 2 楼答案

    use <database_name>
    go
    
    select * from sysobjects where type='U'
    go
    

    这应该列出用户表、存储过程和代理表

  3. # 3 楼答案

    从数据库名称中选择名称。。sysobjects,其中type=“U”

    从db_名称替换实际数据库名称

    类型“U”用于用户定义的表

    谢谢, 戈帕尔