How to change a database name.
Using the db2relocatedb command it's possible to change a database name.
Command syntax:
db2relocatedb -f <config_file>
config file format 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,newContPath1
STORAGE_PATH=oldStoragePath1,newStoragePath1
...
Example:
Our environment:
- Database Name: prod1
- Database Path: /home/db2inst1
- Instance: db2inst1
Create a file called: changeDbName with the following format:
DB_NAME=prod1,prod2
DB_PATH=/home/db2inst1
INSTANCE=db2inst1
and execute the command:
db2relocatedb -f changeDbName
After the change our environment will be:
- Database Name: prod2
- Database Path: /home/db2inst1
- Instance: db2inst1
Notes:
* Database name, database path, and instance name are all required
fields. If one of these fields is not changing then it is not
necessary to list the old and new value for it, just give the
old/current one.
* Blank lines or lines beginning with a comment character (#) will be
ignored.
* Here are all of the tasks where the tool can be useful:
- Changing a database name
- Changing the path/drive that a database was created on
- Changing one or more table space containers
- Changing the log path associated with the database
- Changing the instance associated with a database
- Copying/moving a database to the same (or different) machine and making one or more of the above changes