Govind Gupta
Govind Gupta

Reputation: 1705

DB2 database restore

When I am restoring the database, by default data is going in C drive, but when I installed the db2 that time I specify the path in D drive only. Also, sample database files created by db2 is stored in D drive. Can anyone please tell me what is the issue?

I have run this command:

SELECT * FROM SYSIBMADM.DBPATHS

below is the result i fetched:

LOGPATH- D:\DB2\NODE000\SQL00001\SQLOGDIR\
DB_STORAGE_PATH- C:\
LOCAL_DB_DIRECTORY -  D:\DB2\NODE000\SQLOGDIR\
DBPATH - D:\DB2\NODE000\SQL00001\

I Want to change this DB_STORAGE_PATH C:\ to D:\ for all the database which i will be restoring.

Upvotes: 0

Views: 1368

Answers (2)

fabfas
fabfas

Reputation: 2228

You can run db2set from db2 command line that will confirm you wheather db2 installed on path with other information;

db2-command-line> db2set

DB2_ATS_ENABLE=YES
DB2_CREATE_DB_ON_PATH=YES
DB2INSTPROF=C:\where\db2\installed\IBM\DB2\DB2COPY1
DB2COMM=TCPIP

You can get more information of Directory structure for your installed DB2 database product (Windows) here

You can run the following command SELECT * FROM SYSIBMADM.DBPATHS. This will give details of following variables of your installed db2 database;

  • LOGPATH
  • DB_STORAGE_PATH
  • LOCAL_DB_DIRECTORY
  • DBPATH

These commands will provide you enough information to locate your installed database. Then you can restore your database providing the exact path.

To add a storage path to an existing database, issue the following ALTER DATABASE statement:

ALTER DATABASE database-name ADD STORAGE ON storage-path

After adding one or more storage paths to the database, you may use the ALTER TABLESPACE statement to rebalance table spaces in the database so that they start to use the new storage paths immediately.

Upvotes: 1

data_henrik
data_henrik

Reputation: 17118

DB2 has a configuration parameter for the default path for databases, dftdbpath. In addition, the command db2sampl to create a sample database has an option dbpath to specify where to place that database.

db2sample -dbpath D: 

The above would place the new database on drive D:.

You will find that there are default paths for certain operations. The overview of DB2 database manager configuration parameters has lists most of them.

For your specific issue I would assume that a parameter was changed some time after DB2 was installed and used initially.

For RESTORE be aware that the options TO and DBPATH are ignored if restoring an existing database.

Upvotes: 0

Related Questions