12.7. The db2relocatedb Utility

The db2relocatedb utility renames a database and relocates a database or part of a database you specify in the configuration file. This tool makes the necessary changes to the DB2 instance and database files.

You can alter the following properties of a database using the db2relocatedb utility:

  • The database name

  • The instance it belongs to

  • The database directory

  • The database partition number

  • The log directory (if it does not reside in the database directory)

  • The location of table space containers (if they do not reside in the database directory)

The syntax for the db2relocatedb command is

					db2relocatedb –f
					configuration_file_name
				

The format of the configuration file is

DB_NAME=oldName,newName
DB_PATH=oldPath,newPath
INSTANCE=oldInst,newInst
NODENUM=nodeNumber
LOG_DIR=oldDirPath,newDirPath
CONT_PATH=oldContPath1,newContPath1
CONT_PATH=oldContPath2,newContPath2
...

If the sample database belongs to instance db2inst1 and was created under /data, to rename the sample database to sample1, edit a configuration file as follows and run the db2relocatedb command using this file:

DB_NAME=SAMPLE,SAMPLE1
DB_PATH=/data
INSTANCE=db2inst1

To move the sample database from the instance db2inst1 on path /data to instance db2inst2 on the same path, do the following:

  • Move all the files in /data/db2inst1 to /data/db2inst2

  • Edit a configuration file as follows and run db2relocatedb using this file:

    DB_NAME=SAMPLE
    DB_PATH=/data
    INSTANCE=db2inst1, dn2inst2
    

If the sample database belongs to instance db2inst1, was created under /data, and has a SMS table space container /home/db2inst1/ts1 must be moved to /home/db2inst1/ts/ts1, do the following:

  • Copy all the files in /home/db2inst1/ts1 to /home/db2inst1/ts/ts1.

  • Edit a configuration file and run db2relocatedb using this file:

    DB_NAME=SAMPLE
    DB_PATH=/data
    INSTANCE=db2inst1
    CONT_PATH=/home/db2inst1/ts1,/home/db2inst1/ts/ts1
    

Refer to the file Command_and_SQL_Examples.pdf included with the CD-ROM accompanying this book for more examples on how to use db2relocatedb.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.75.165