查询Sybase ASE 对象如 tables, views, indexes, procedures, triggers, schemas, and users.

来源:互联网 发布:中国动画电影制作软件 编辑:程序博客网 时间:2024/05/16 08:34

查询Sybase objects such as tables, views, indexes, procedures, triggers, schemas, and users.

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

 

Owners

This is a query to get all Sybase owners. 

select name from dbo.sysusers where uid < 16384 order by name

 

Procedures

This is a query to get all Sybase procedures. 

exec sp_stored_procedures '%' 

The query can be filtered to return procedures for specific owners and databases by appending more information onto the procedure call, such as the following: 

exec sp_stored_procedures '%', 'dbo', 'master'

 

Procedure Columns

This is a system stored procedure call to get the columns in a Sybase procedure. 

exec sp_sproc_columns 'get_employee_names', 'dbo', 'sample'

 

Triggers

This is a query to get all Sybase triggers. 

select * from sysobjects where type = 'TR' 

The query can be filtered to return triggers for a specific owner by appending a user_name call onto the where clause to the query. 

select * from sysobjects where type = 'TR' and user_name(sysobjects.uid) = 'dbo'

 

Indexes

This is a query to get Sybase indexes for a particular table. In this example, the table used is employee. 


exec sp_helpindex 'employee'



转自:http://razorsql.com/articles/sybase_admin_queries.html

0 0