DB2 9.7 Error: SQL1005N The database alias already exists

Problem

When trying to restore a database from backup, you might get an SQL1005N “The database alias “dabase_name” already exists in either the local database directory or system database directory.”

Solution


$ export DB2NODE=0
$ db2 terminate
DB20000I The TERMINATE command completed successfully.
$ db2 restore database <dabase_name> from <source_directory> to <destination>
SQL1005N The database alias "dabase_name" already exists in either the local
database directory or system database directory. SQLSTATE=00000
$ db2 update dbm cfg using DFTDBPATH <destination>
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
$ db2 create database sample at dbpartitionnum
DB20000I The CREATE DATABASE AT NODE command completed successfully.
$ db2 restore database <dabase_name> from <source_directory> to <destination>
SQL2539W Warning! Restoring to an existing database that is the same as the backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.

Note that on DB2 9.7 the command

$ db2 terminate

allows you to refresh the catalog directory cache.

References

This entry was posted in DB2 and tagged , . Bookmark the permalink.

NewPush has solutions to fit your business needs.  For more than a decade, our focus has been to take on the technical challenges that are the hardest and most time-consumming.  Our goal is to free up your resources to focus on the core activities of your business and to drive your business performance.  Please visit our main site at newpush.com for more information or call us at +1-303-423-4500.