Assigning space and devices to databases

Adaptive Server allocates storage space to databases when a user enters the create database or alter database command. create database can specify one or more database devices, along with the amount of space on each that is to be allocated to the new database.

NoteYou can also use the log on clause to place a production database’s transaction log on a separate device. See “Placing the transaction log on a separate device” for more information.

If you use the default keyword, or if you omit the on clause, Adaptive Server puts the database on one or more of the default database devices specified in master..sysdevices. See “Designating default devices” for more information about the default pool of devices.

To specify a size (4MB in the following example) for a database that is to be stored in a default location, use on default = size like this:

create database newpubs
on default = "4M"

To place the database on specific database devices, give the name(s) of the database device(s) where you want it stored. You can request that a database be stored on more than one database device, with a different amount of space on each. All the database devices named in create database must be listed in sysdevices. In other words, they must have been initialized with disk init. See Chapter 16, “Initializing Database Devices,” for instructions about using disk init.

The following statement creates the newdb database and allocates 3MB on mydata and 2MB on newdata. The database and transaction log are not separated:

create database newdb
on mydata = "3M", newdata = "2M"

WARNING! Unless you are creating a small or noncritical database, always place the log on a separate database device. Follow the instructions under “Placing the transaction log on a separate device” to create production databases.

If the amount of space you request on a specific database device is unavailable, Adaptive Server creates the database with as much space as possible on each device and displays a message informing you how much space it has allocated on each database device. This is not considered an error. If there is less than the minimum space necessary for a database on the specified database device, create database fails.

If you create (or alter) a database on a UNIX device file that does not use the dsync setting, Adaptive Server displays an error message in the error log file. For example, if you create the “mydata” device in the previous example does not use dsync, you would see a message similar to:

Warning: The database 'newdb' is using an unsafe virtual device 'mydata'. The recovery of this database can not be guaranteed.