Search code examples
db2db2-luw

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.


Solution

  • 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.