【问题标题】:how to get list of user defined tables in the specific database in sybase如何在sybase中获取特定数据库中用户定义的表列表
【发布时间】:2013-09-02 21:37:00
【问题描述】:

我需要在sybase中列出特定数据库中所有表的名称,然后根据名称中的一些字符串过滤这些表名。

这给出了当前数据库,但我不能指定特定的数据库

select name from sysobjects where type = 'U'

这不仅仅是表格,它包括触发器和存储过程

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

有没有人知道怎么做,并通过名称中的某些字符串过滤表的名称,例如只显示名称中带有 SASSA 的表?

【问题讨论】:

    标签: java sql sybase


    【解决方案1】:

    使用sp_tables

    sp_tables [table_name] [, table_owner] 
        [, table_qualifier][, table_type]
    

    其中 *table_qualifier* 是数据库的名称。

    Tables and Views

    要获取所有表、视图和系统表,以下 Sybase 可以执行系统存储过程。

    exec sp_tables '%'

    仅按数据库过滤表,例如master:

    exec sp_tables '%', '%', 'master', "'TABLE'"

    仅按数据库和所有者/架构过滤表,例如, 大师和dbo:

    exec sp_tables '%', 'dbo', 'master', "'TABLE'"

    要仅返回视图,请将“'TABLE'”替换为“'VIEW'”。只返回 系统表,将“'TABLE'”替换为“'SYSTEM TABLE'”。

    【讨论】:

      【解决方案2】:

      从 db_name..sysobjects 中选择名称,其中 type ="U"

      用 db_name 替换实际的数据库名称。

      类型 'U' 用于用户定义的表。

      谢谢, 戈帕尔

      【讨论】:

        【解决方案3】:
        use <database_name>
        go
        
        select * from sysobjects where type='U'
        go
        

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2010-12-05
          • 1970-01-01
          • 2022-12-07
          • 2011-03-10
          • 2022-11-24
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多