Quantcast
Channel: Sybase – How to Guides and Knowledge Feed
Viewing all articles
Browse latest Browse all 26

Get Sybase Database Information

$
0
0

We can get the information about databases and its objects using sytem procedures, built-in functions and system tables. sp_helpdb reports database(s) information like name,db_size,owner,dbid,created,durability,status.

To get list of databases in ASE:
We can get the list of databases(system and user databases) either using sp_helpdb or sysdatabases. Sysdatabases table gives us more information than sp_helpdb, but doesnt provide the segment information. sp_databases procedures gives only database name, size information.

To get particular database information:
Syntax: sp_helpdb database_name

Example:

sp_helpdb k2schools


Output:

Get Sybase Database Information

To get all databases(system databases and user databases) information:
sp_helpdb

Using System Table: We can get databases information using sysdatabases table. But, this can be run only on master database or use master..sysdatabases.

To get particular database information:

Example1:

1> use k2schools
2> go
1> select * from sysdatabases where name = ‘k2schools’
2> go

To get all databases(system databases and user databases) information:

1> select *from sysdatabases
2> go

To get only databases(system databases and user databases) names:

1> select name from sysdatabases
2> go
name
————————————————————
k2schools
master
model
pubs2
pubs3
sybsystemdb
sybsystemprocs
tempdb

Using sp_databases: This gives only database name, database size and remarks information.

1> sp_databases
2> go
database_name database_size remarks
master 26624 NULL
model 6144 NULL
tempdb 108544 NULL
sybsystemdb 12288 NULL
sybsystemprocs 200704 NULL
pubs2 7168 NULL
pubs3 6144 NULL
k2schools 307200 NULL
(8 rows affected)

To get ddatabase using dbid in Sybase:

Get Sybase Database Information.1jpg


Viewing all articles
Browse latest Browse all 26

Trending Articles