Use the mount command to attach a database to a destination or secondary Adaptive Server. The mount command decodes the information in the manifest file and makes the set of databases available. The mount command differs from other copying procedures such as the bcp bulk copy utility in that all required supporting activities are executed, including adding database devices, if necessary, and activating them, creating the catalog entries for the new databases, and recovering them.
If you are using different device names at the destination Adaptive Server when mounting the databases, use mount with listonly and modify the device path names at the destination server. Then use mount to actually mount the databases.
For every login that is allowed access to a database on the original Adaptive Server, it is more convenient to have a corresponding login for the same suid at the destination Adaptive Server, as this avoids user ID reconciliation issues.
For permissions to remain unchanged, the login maps at the destination Adaptive Server must be identical to that on the source Adaptive Server. For more information on login maps, see Chapter 15, “Managing Remote Servers” in System Administration Guide, Volume 1.
mount database all | database_mapping[, database_mapping, ...] from "manifest_file" [using device_mapping [, device_mapping...] [with listonly] database_mapping: origdbname as newdbname | newdbname = origdbname | origdbname | newdbname device_mapping logical_device_name as new_physical_name | new_physical_name = logical_device_name | original_physical_name | new_physical_name
The manifest file is the binary file that describes the databases that are present on a set of database devices.
Operations that can perform character translations of the file contents (such as ftp) corrupt the manifest file unless performed in binary mode.
Finds the path names listed on the manifest file from the source Adaptive Server:
mount database all from "/data/sybase2/mfile1" with listonly go
[database] mydb [device] "/data/sybase1/d0.dbs" = "1dev1" "/data/sybase2/d14.dbs" = "1dev13"
When you use the path names different from the source ones, verify or modify them to meet your criteria at the destination Adaptive Server.
After the database devices are copied to the secondary Adaptive Server, you then mount it:
mount database all from "/data/sybase2/mfile1" using "/data/sybase2/d0.dbs" = "1dev1", "/data/sybase2/d14.dbs" = "1dev13"
When the mount process has completed, the database or databases are still offline. Use the online database command to bring them online. You need not restart the server.
The destination server can be the same as the source server. In this case, the database names must be mapped to a different name, and the logical device names will be internally renamed.
Create an exact copy of database mydb in the same server:
1> quiesce database mydb_tag hold mydb for external dump to "/data/mydb.manifest" 2> go
Copy the OS file:
$ cp /data/sybase2/mydb.dbs /data/sybase2/mydb_copy.dbs
You can now mount it as a copy:
1> quiesce database mydb_tag release 2> go 1> mount database mydb as mydb_copy 2> from "/data/mydb.manifest" 3> using mydb_dev as "/data/sybase2/mydb_copy.dbs" 3> go
The physical device //data/sybase2/mydb_copy.dbs/ is automatically assigned a machine-generated logical name with the format Cccc$<mydb_dev> where:
C – is [A–Z]
c – is [A–Z, 0–9], and refers to the encoded logical device number
mydb_dev – contains up to 26 characters from the old logical device name.
Database IDs for the transported databases should not exist on the destination Adaptive Server. Because the database has been mounted on the same server, the database ID had to be changed. The allocation pages in the mounted device keep the original database ID, and that information is used by the disk refit command. Use the dbcc checkalloc command to reconcile the dbid after running mount database so that disk refit can work on the mounted devices. Run checkalloc if the database is not being mounted for temporary use.
The using clause allows you to define a mapping via the “=” sign or the “as” clause.
If there are more than one device, a mapping can be one using “=” and another using “as.”
In both databases and devices, you can map devices by name, specifying both logical and physical, and by order. If a database is mapped by name, all databases must be mapped by name and vic eversa. The same happens for devices.
Once databases are mounted on the destination Adaptive Server, certain settings are cleared on the mounted database:
Replication is turned off.
Audit settings are cleared and turned off.
Component Integration Services options, default remote location, and type are cleared.
Cache bindings are dropped for both the mounted databases and their objects.
Recovery order is dropped for the mounted databases and becomes the default dbid order.
You cannot use the mount command in a transaction.
You cannot mount a database on server configured for high availability.
When you mount databases onto an Adaptive Server, if you change the dbid of the database you are mounting, all procedures are marked for recompilation in the database. This increases the time it takes to recover the database at the destination, and delays the first execution of the procedure.
The manifest file contains the device paths known to the source Adaptive Server that created the manifest file. If the destination Adaptive Server accesses the devices with a different path, you can specify the new path to the mount command.
Use the mount command with listonly to display the old path:
mount database all from "/work2/Mpubs_file" with listonly go
[database] mydb [device] "/work2/Devices/pubsdat.dat" = "pubs2dat"
If the new path for the device pubs2dat is /work2/Devices/pubsdevice.dat (the devices path in Windows), specify the new device in the mount command:
mount database all from "/work2/Mpubs_file" using "/work2/datadevices/pubsdevice.dat" = "pubs2dat"
If the logical device names exist in the destination server, they will be renamed using an automatically generated unique name.
ANSI SQL – Compliance level: Transact-SQL extension.
mount requires an SA role.
Values in event and extrainfo columns of sysaudits are:
Event |
Audit option |
Command or access audited |
Information in extrainfo |
---|---|---|---|
101 |
mount |
mount database |
|
Commands unmount, quiesce database
Documentation Chapter 7, “Database Mount and Unmount,” in System Administration Guide Volume 2