Chapter 4 Database Administration Utilities
141
Typically, you would create a new database using the Initialization utility,
and then reload it using this switch. This method is useful when you want to
change the initialization options, such as page size, or collation.
For example, the following command (which should be entered all on one
line) loads a copy of the
asademo.db
database into an existing database file
named
newdemo.db
:
dbunload -c "uid=dba;pwd=sql;dbf=asademo.db" -ac
"uid=dba;pwd=sql;dbf=newdemo.db"
If you use this option, no interim copy of the data is created on disk, so you
do not specify an unload directory on the command line. This provides
greater security for your data, but at some cost for performance.
Create a database for reloading (–an) You can combine the operations
of unloading a database, creating a new database, and loading the data using
this option. This option applies to personal server connections, and network
server connections over shared memory.
Typically, you would use this switch when you do not want to change the
initialization option of your database. The options specified when you
created the source database are used to create the new database.
For example, the following command (which should be entered all on one
line) creates a new database file named
asacopy.db
and copies the schema
and data of
asademo.db
into it:
dbunload -c "uid=dba;pwd=sql;dbf=asademo.db" -an
asacopy.db
If you use this option, no interim copy of the data is created on disk, so you
do not specify an unload directory on the command line. This provides
greater security for your data, but at some cost for performance.
Rebuild and replace database (–ar) This option creates a new database
with the same settings as the old database, reloads it, and replaces the old
database. If you use this option, there can be no other connections to the
database, and the database connection must be local, not over a network.
If you specify directory, the transaction log offsets are reset for replication
purposes, and the transaction log from the old database is moved to the
specified directory. The named directory should be the directory that holds
the old transaction logs used by the Message Agent and the Replication
Agent. The transaction log management is handled only if the database is
used in replication: if there is no SQL Remote publisher or LTM check, then
the old transaction log is not needed and is deleted instead of being copied to
the specified directory.