简体   繁体   English

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

[英]how to get list of user defined tables in the specific database in sybase

I need to list the name of all tables in the specific database in sybase and then filter these table name according some string in the name. 我需要在sybase中列出特定数据库中所有表的名称,然后根据名称中的某个字符串过滤这些表名。

this gives current database but i cant specify specific database 这给了当前数据库,但我不能指定特定的数据库

select name from sysobjects where type = 'U'

this gives more than tables, it includes trigger and stored procedure 这不仅提供了表,还包括触发器和存储过程

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

does any body know how to do it and also filter the name of tables by some string in the name for example only the table with the SASSA in the name be displayed? 是否有任何正文知道如何做,并且还通过名称中的某个字符串过滤表的名称,例如,只显示名称中带有SASSA的表?

Use sp_tables . 使用sp_tables

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

where *table_qualifier* is the name of the database. 其中* table_qualifier *是数据库的名称。

Tables and Views 表格和视图

To get all tables, views, and system tables, the following Sybase system stored procedure can be executed. 要获取所有表,视图和系统表,可以执行以下Sybase系统存储过程。

exec sp_tables '%' exec sp_tables'%'

To filter by database for tables only, for example master: 要按数据库筛选表,例如master:

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

To filter by database and owner / schema for tables only, for example, master and dbo: 要仅按表的数据库和所有者/架构进行筛选,例如master和dbo:

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

To return only views, replace "'TABLE'" with "'VIEW'". 要仅返回视图,请将“'TABLE'”替换为“'VIEW'”。 To return only system tables, replace "'TABLE'" with "'SYSTEM TABLE'". 要仅返回系统表,请将“'TABLE'”替换为“'SYSTEM TABLE'”。

Select name from db_name..sysobjects where type ="U" 从db_name..sysobjects中选择名称,其中type =“U”

replace actual database name from db_name. 从db_name替换实际的数据库名称。

type 'U' is for userdefined table. 类型“ U”用于用户定义的表。

Thanks, Gopal 谢谢Gopal

use <database_name>
go

select * from sysobjects where type='U'
go

This should list the user tables,stored procedures and proxy tables. 这应该列出用户表,存储过程和代理表。

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

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