DB2 Database – Cloning Within a Single Instance

db2db2-luw

I need to create an exact copy of a Db2 database (V11.1+) on the same server within the same instance. (This is a development server that does not run production databases.)

This is how I do it now.

  1. Dump tables using a hand-written script
  2. Create a new database
  3. Import service functions specific to my application to the database
  4. Create a schema in the new database
  5. Import data from a dump into the new database
  6. Set database configuration parameters for the new database

I read that it is possible to copy a database scheme with db2move.
Is there a simple approach that could be used to perform a full copy?

Best Answer

This is a minimial example of copying a database (test) to a into a new database (test2)

db2 create database test
db2 backup database test to /tmp
db2 restore database test from /tmp into test2
db2 connect to test2


   Database Connection Information

 Database server        = DB2/LINUXX8664 11.1.3.3
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST2