繁体   English   中英

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

[英]how to get list of user defined tables in the specific database in 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 *是数据库的名称。

表格和视图

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

exec sp_tables'%'

要按数据库筛选表,例如master:

exec sp_tables'%','%','master',''TABLE'“

要仅按表的数据库和所有者/架构进行筛选,例如master和dbo:

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

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

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

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

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

谢谢Gopal

use <database_name>
go

select * from sysobjects where type='U'
go

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM