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

17,137

Solution 1

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

replace actual database name from db_name.

type 'U' is for userdefined table.

Thanks, Gopal

Solution 2

Use sp_tables.

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

where *table_qualifier* is the name of the database.

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

Solution 3

use <database_name>
go

select * from sysobjects where type='U'
go

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

Share:
17,137
michdraft
Author by

michdraft

A java developer.

Updated on June 05, 2022

Comments

  • michdraft
    michdraft about 2 years

    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.

    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?