Database storage information is listed in master..sysusages.
Each row in master..sysusages represents a space allocation assigned to a database. Thus, each database has one row in sysusages for each time create database or alter database assigns a fragment of disk space to it.
master, with a dbid of 1
The temporary database, tempdb, with a dbid of 2
model, with a dbid of 3
sybsystemdb, with a dbid of 31513
sybsystemprocs, with a dbid of 31514
If you upgraded SAP ASE from an earlier version, databases sybsystemdb and sybsystemprocs may have different database IDs.
If you installed auditing, the sybsecurity database is dbid 5.
As you create new databases, or enlarge existing ones, new rows are added to sysusages to represent new database allocations.
Here is what sysusages might look like on an SAP ASE that includes the five system databases and one user database. The user database was created with the log on option, and was extended once using alter database. It has a database ID (dbid) of 4:
select dbid, segmap, lstart, size, vdevno, vstart from sysusages order by 1
dbid segmap lstart size vdevno vstart ---- --------- ---------- -------- -------- ----------- 1 7 0 6656 0 4 2 7 0 2048 0 8196 3 7 0 1536 0 6660 4 3 0 5120 2 0 4 4 5120 2560 3 0 4 3 7680 5120 2 5120 31513 7 0 1536 0 10244 31514 7 0 63488 1 0
@@maxpagesize – logical page size
@@pagesize – virtual page size
select dbid, db_name(dbid) as 'database name', lstart, size / (power(2,20)/@@maxpagesize) as 'MB', d.name from sysusages u, sysdevices d where u.vdevno = d.vdevno and d.status & 2 = 2 order by 1 compute sum(size / (power(2,20)/@@maxpagesize)) by dbid
dbid database name lstart MB device name ------ -------------- -------- -------- -------------------- 4 test 0 10 datadev 4 test 5120 5 logdev 4 test 7680 10 datadev Compute Result: ----------- 25
select dbid, segmap from master..sysusages where dbid = 6
dbid segmap ------ ----------- 6 3 6 4
sp_addsegment newseg, testdb, datadev
create table abcd ( int c1 ) on newseg
select dbid, segmap from sysusages where dbid=6 dbid segmap ------ ----------- 6 11 6 4
Note that the segment mapping for the user database has changed from a value of 3 to a value of 11, which shows that segment mappings for user databases change when you reconfigure a database.
sp_helpsegment
segment name status ------- ---------------- ---------- 0 system 0 1 default 1 2 logsegment 0 3 newseg 0
The segment newseg is not part of the default pool.
sp_addsegment newseg1, testdb, datadev
select dbid, segmap from sysusages
dbid segmap ------ ----------- 6 27 6 4