jan 262012
O programa db2relocatedb também pode ser utilizado para trocar o nome do banco de dados.
Este procedimento geralmente é necessário para a criação de um banco de deenvolvimento ou homologação, baseado em uma restauração do banco de produção.
Para alterar o nome do banco, basta indicar no parâmetro DB_NAME do arquivo relocate.cfg o antigo e o novo nome do banco.
[db2inst1@nerv00 ~]$ vi relocate.cfg
[db2inst1@nerv00 ~]$ cat relocate.cfg
DB_NAME=SAMPLE,PRD
DB_PATH=/home/db2inst1
INSTANCE=db2inst1
NODENUM=0
[db2inst1@nerv00 ~]$ db2stop force
SQL1064N DB2STOP processing was successful.
[db2inst1@nerv00 ~]$ db2relocatedb -f relocate.cfg
Files and control structures were changed successfully.
Database was catalogued successfully.
DBT1000I The tool completed successfully.
[db2inst1@nerv00 ~]$ db2start
SQL1063N DB2START processing was successful.
[db2inst1@nerv00 ~]$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.5
You can issue database manager commands and SQL statements from the command
prompt. For example:
db2 => connect to sample
db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
? CATALOG DATABASE for help on the CATALOG DATABASE command
? CATALOG for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
db2 => CONNECT TO SAMPLE
SQL30061N The database alias or database name "SAMPLE " was not
found at the remote node. SQLSTATE=08004
db2 => CONNECT TO PRD
Database Connection Information
Database server = DB2/LINUXX8664 9.7.5
SQL authorization ID = DB2INST1
Local database alias = PRD
db2 => QUIT
DB20000I The QUIT command completed successfully.
[db2inst1@nerv00 ~]$