Getting help on databases

sp_helpdb can report information about a specified database or about all Adaptive Server databases. It reports the name, size, and usage of each fragment you have assigned to the database.

sp_helpdb [dbname] 

For example, to display a report on pubs2:

sp_helpdb pubs2
name    db_size   owner  dbid created           status 
-----   -------   ------ ---- ---------------   -------------
pubs2   2 MB      sa     4    Jun 18 1997       no options set
 
(1 row affected)
device             size         usage
-----------------  -----------  -------------- 
pubsdev            2 MB         data + log
 
(1 row affected) 

sp_databases lists all the databases on a server. For example:

sp_databases
database_name     database_size  remarks
----------------- -------------  ------------
master                     5120  NULL 
model                      2048  NULL
pubs2                      2048  NULL 
pubs3                      2048  NULL
sybsecurity                5120  NULL
sybsystemprocs            30720  NULL
tempdb                     2048  NULL
 
(7 rows affected, return status = 0)

To find out who owns a database, use sp_helpuser:

sp_helpuser dbo
Users_name    ID_in_db Group_name   Login_name
------------- -------- ------------ ------------
dbo                  1 public       sa
 
(return status = 0)

Use db_id() and db_name() to identify the current database. For example:

select db_name(), db_id()
------------------------------ ------
master                              1