Understanding disks, devices, databases, and segments

Figure 16-1 shows the various layouts of physical resources that may exist in an Adaptive Server installation after a series of disk init, create database, and alter database operations. You can use this information to devise different plans of physical and logical space layout while testing stored procedures.

Figure 16-1: Database and device layouts

Graphic showing a series of bar graphs depicting the database and device layouts. This graphic is described in the text prior to the graphic.

Raw disks can be partially occupied by a Sybase device. syb_device2 shows an entire raw disk fully occupied by a single Sybase device, on which multiple databases were created. On this raw disk (/dev/vx/rdsk/sybase2/vol02), there is still some empty space at the head of the device, which can happen when a database that initially occupied this space is subsequently dropped.

syb_device4 and syb_device5 show the layout of Sybase devices /agni4/syb_device4.dat and /agni5/syb_device5.dat on a file system disk, where the Sybase device occupies a portion of the disk, but there is still room for the device (an operating system file, for instance) to grow.

syb_device6 shows a Sybase file system disk that has fully occupied the entire available space on the physical disk, but still has unused space on the device. This space can be used to expand existing databases on this device.

These various devices illustrate database fragments for different databases. Each device for a particular database has one or more segments spanning that device.

In syb_device6, /agni6/syb_device6.dat, db1 spans three separate pieces of the device. That device also belongs to three different segments, data segments 1, 2, and 3. All three entries in sysusages for this database, db1, appear with a segment map value that includes all three segments.

However, on the device syb_device3 on /dev/raw/raw3, the database has two pieces of the device, and one of them is exclusively marked as for the log segment while the other is marked as for the default segment. Assuming that an initial create database command has already been executed, the following SQL commands can produce this result:

alter database db1 on syb_device3 = "30M"
alter database db1 log on syb_device3 = "10M" with       override

The first alter database command creates the database piece of default segment, and the second one creates the database piece of logsegment, forcing an override even though both pieces are on the same device. Space is expanded on a database in individual segments.