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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18528120/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 08:47:17  来源:igfitidea点击:

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

javasqlsybase

提问by michdraft

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 SASSAin the name be displayed?

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

采纳答案by Gopal Sanodiy

Select name from db_name..sysobjects where type ="U"

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

replace actual database name from db_name.

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

type 'U' is for userdefined table.

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

Thanks, Gopal

谢谢,戈帕尔

回答by Sajal Dutta

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.

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

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

exec sp_tables '%'

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

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

仅按数据库和所有者/模式过滤表,例如 master 和 dbo:

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

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

回答by user115806

use <database_name>
go

select * from sysobjects where type='U'
go

This should list the user tables,stored procedures and proxy tables.

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