Makes a physical device or file usable by Adaptive Server.
disk init name = "device_name" , physname = "physicalname" , [vdevno = virtual_device_number ,] size = number_of_blocks [, vstart = virtual_address , cntrltype = controller_number ] [, contiguous] [, dsync = { true | false } ]
is the name of the database device or file. The name must conform to the rules for identifiers and must be enclosed in single or double quotes. This name is used in the create database and alter database commands.
is the full specification of the database device. This name must be enclosed in single or double quotes.
is the virtual device number, which must be unique among the database devices associated with Adaptive Server. The device number 0 is reserved for the master device. Valid device numbers are between 1 and 255, but the highest number must be one less than the number of database devices for which your Adaptive Server is configured. For example, for an Adaptive Server with the default configuration of 10 devices, the available device numbers are 1 – 9. To see the maximum number of devices available on Adaptive Server, run sp_configure, and check the number of devices value.
To determine the virtual device number, look at the device_number column of the sp_helpdevice report, and use the next unused integer.
is the amount of space to allocate to the database extension. size can be in the following unit specifiers: ‘k’ or ‘K’ (kilobytes), ‘m’ or ‘M’ (megabytes), and ‘g’ or ‘G’ (gigabytes). Sybase recommends that you always include a unit specifier. Quotes are optional if you do not include a unit specifier. However, you must use quotes if you include a unit specifier.
is the starting virtual address, or the offset, for Adaptive Server to begin using the database device. vstart accepts the following optional unit specifiers: ‘k’ or ‘K’ (kilobytes), ‘m’ or ‘M’ (megabytes), and ‘g’ or ‘G’ (gigabytes). The size of the offset depends on how you enter the value for vstart.
If you do not specify a unit size, vstart uses
2K pages for its starting address. For example, if you specify vstart = 13
,
Adaptive Server uses 13 * 2K pages as the offset for the
starting address.
If you specify a unit value, vstart uses
this as the starting address. For example, if you specify vstart = "13M"
,
Adaptive Server sets the starting address offset at 13 megabytes.
The default value (and usually the preferred value) of vstart is 0. If the specified device does not have the sum of vstart + size blocks available, the disk init command fails. If you are running the Logical Volume Manager on an AIX operating system. vstart should be 2. Specify vstart only if instructed to do so by Sybase Technical Support.
specifies the disk controller. Its default value is 0. Reset cntrltype only if instructed to do so by Sybase Technical Support.
UNIX platforms only – specifies whether writes to the database device take place directly to the storage media, or are buffered when using UNIX operating system files. This option is meaningful only when you are initializing a UNIX operating system file; it has no effect when initializing devices on a raw partition. By default, all UNIX operating system files are initialized with dsync set to true.
Initializes 5MB of a disk on a UNIX system:
disk init name = "user_disk", physname = "/dev/rxy1a", vdevno = 2, size = 5120
Initializes 10MB of a disk on a UNIX operating system file. Adaptive Server opens the device file with the dsync setting, and writes to the file are guaranteed to take place directly on the storage media:
disk init name = "user_file", physname = "/usr/u/sybase/data/userfile1.dat", vdevno = 2, size = 5120, dsync = true
The master device is initialized by the installation program; you need not initialize this device with disk init.
To successfully complete disk initialization, the “sybase” user must have the appropriate operating system permissions on the device that is being initialized.
You can specify the size as a float, but the size is rounded down to the nearest multiple of 2K.
If you do not use a unit specifier for size:
disk init uses the virtual page size of 2K.
The size argument for create database and alter database is in terms of megabytes of disk space. This value is converted to the number of logical pages the master device was built with
.
The minimum size of a disk piece that you can initialize using disk init is the larger of:
One megabyte
One allocation unit of the server’s logical page size
Use disk init for each new database device. Each time disk init is issued, a row is added to master..sysdevices. A new database device does not automatically become part of the pool of default database storage. Assign default status to a database device with sp_diskdefault.
Back up the master database with the dump database or dump transaction command after each use of disk init. This makes recovery easier and safer in case master is damaged. If you add a device with disk init and fail to back up master, you may be able to recover the changes by using disk reinit, then stopping and restarting Adaptive Server.
Assign user databases to database devices with the name clause of the create database or alter database command.
The preferred method for placing a database’s transaction log (the system table syslogs) on a different device than the one on which the rest of the database is stored, is to use the log on extension to create database. Alternatively, you can name at least two devices when you create the database, then execute sp_logdevice. You can also use alter database to extend the database onto a second device, then run sp_logdevice. The log on extension immediately moves the entire log to a separate device. The sp_logdevice method retains part of the system log on the original database device until transaction activity causes the migration to become complete.
For a report on all Adaptive Server devices on your system (both database and dump devices), execute sp_helpdevice.
Remove a database device with sp_dropdevice. You must first drop all existing databases on that device.
If disk unit failed because the size value is too large for the database device, use a different virtual device number or restart Adaptive Server before executing disk unit again.
Do not set dsync to false for
any device that stores critical data. The only exception is tempdb,
which can safely be stored on devices for which dsync is set
to false.
When dsync is on, writes to the database device are guaranteed to take place on the physical storage media, and Adaptive Server can recover data on the device in the event of a system failure.
When dsync is off, writes to the database device may be buffered by the UNIX file system. The UNIX file system may mark an update as being completed, even though the physical media has not yet been modified. In the event of a system failure, there is no guarantee that data updates have ever taken place on the physical media, and Adaptive Server may be unable to recover the database.
dsync is always on for the master device file.
The dsync value should be turned off only when databases on the device need not be recovered after a system failure. For example, you may consider turning dsync off for a device that stores only the tempdb database.
Adaptive Server ignores the dsync setting for devices stored on raw partitions—writes to those device are guaranteed to take place on the physical storage media, regardless of the dsync setting.
The dsync setting is not used on the Windows NT platform.
disk reinit ensures that master..sysdevices is correct if the master database has been damaged or if devices have been added since the last dump of master.
ANSI SQL – Compliance level: Transact-SQL extension.
disk init permission defaults to System Administrators and is not transferable. You must be using the master database to use disk init.
Commands alter database, create database, disk refit, disk reinit, dump database, dump transaction, load database, load transaction
System procedures sp_diskdefault, sp_dropdevice, sp_helpdevice, sp_logdevice