Sybase Admin - Queries
Listed below are queries / stored procedure calls that can be used to get information on 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'".
This is a query to get all Sybase owners.
select name from dbo.sysusers where uid < 16384 order by name
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'
This is a system stored procedure call to get the columns in a Sybase procedure.
exec sp_sproc_columns 'get_employee_names', 'dbo', 'sample'
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'
This is a query to get Sybase indexes for a particular table. In this example, the table
used is employee.
exec sp_helpindex 'employee'