Sie sind auf Seite 1von 2

Listed below are queries / stored procedure calls that can be used to get inform ation on Sybase objects

such as tables, views, indexes, procedures, triggers, sc hemas, 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 an d dbo: exec sp_tables '%', 'dbo', 'master', "'TABLE'" To return only views, replace "'TABLE'" with "'VIEW'". To return only system tab les, 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, t he table used is employee. exec sp_helpindex 'employee' ********************************************************** SELECT * FROM sysobjects WHERE type = 'U' You can change 'U' to other objects: C D F L N P PR R RI S TR U V XP List computed column default SQLJ function log partition condition Transact-SQL or SQLJ procedure prepare objects (created by Dynamic SQL) rule referential constraint system table trigger user table view extended stored procedure of columns in a table:

SELECT * FROM syscolumns sc INNER JOIN sysobjects so ON sc.id = so.id WHERE so. name = 'my_table_name'

Das könnte Ihnen auch gefallen