Avatar of Jim Youmans
Jim Youmans
Flag for United States of America asked on

DB2 Restore to different database name on same server

DB2 10.5 on Windows

I want to restore my test database on a windows server to test2 database on the same server but I am a bit confused by the RESTORE WITH REDIRECT method.

So the test database is on the D: drive and I want to put the test2 database on the Z: drive.  I ran the RESTORE ... REDIRECT GENERATE SCRIPT so I have a script to work with.  The script has all the tablespaces for the test db in it but it is all commented out.  Like this.

-- *****************************************************************************
-- ** Tablespace name                                  = SYSCATSPACE
-- **   Tablespace ID                                      = 0
-- **   Tablespace Type                                 = Database managed space                      
-- **   Tablespace Content Type                  = All permanent data. Regular table space.    
-- **   Tablespace Page size (bytes)            = 4096
-- **   Tablespace Extent size (pages)        = 4
-- **   Using automatic storage                  = Yes    
-- **   Storage group ID                                = 0
-- **   Source storage group ID                   = -1
-- **   Data tag                                                = None
-- **   Auto-resize enabled                           = Yes    
-- **   Total number of pages                      = 501844
-- **   Number of usable pages                   = 501840
-- **   High water mark (pages)                   = 113376
-- *****************************************************************************

Do I need to create these tablespaces before I do the restore or will the restore command automatically create them on the new drive?

Same question with log files.  Here is what the restore script currently has.

INTO test
-- LOGTARGET '<directory>'
-- NEWLOGPATH 'L:\db2logs\test\NODE0000\LOGSTREAM0000\'

I know I need to change the INTO command to INTO test2 and L: is the current log file path for Test and I want to change it to the new drive (Z:) but do I have to create the directory first or will the restore do it?

I appreciate any and all help.


DatabasesWindows OSDB2Storage Software

Avatar of undefined
Last Comment
Kent Olsen

8/22/2022 - Mon
Kent Olsen

Hi Jim,

The IBM docs have a pretty good description of the process:


In a nutshell, you can put the database on any device or file system with the SET TABLESPACE CONTAINERS command:


Jim Youmans

So if I have 20 tablespaces, I would need to define them all via the SET TABLESPACE CONTAINERS?
Kent Olsen

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck