You can use the RESTORE DATABASE command with the TRANSPORT option to copy a set of table spaces and SQL schemas from one database to another database.
The following examples use a database named ORIGINALDB as source of the backup image and the target database TARGETDB.
If there exists a single online backup image for ORIGINALDB that contains all of the table spaces in the database, then this will be the source for the transport. This also applies to table space level backup images.
You can redirect the container paths for the table spaces being transported. This is especially important if database relative paths were used.
db2 restore db originaldb tablespace (mydata1) schema(schema1,schema2)
from <Media_Target_clause> taken at <date-time>
transport into targetdb redirect
db2 list tablespaces
db2 set tablespace containers for <tablespace ID for mydata1>
using (path '/db2DB/data1')
db2 restore db originaldb continue
db2 restore db originaldb tablespace (mydata2,myindex) schema(schema3)
transport into targetdb
The transport operation will
fail because the schema schema3 already exists on the target database.
TARGETDB will remain unchanged. SQLCODE=SQL2590N rc=3.db2 restore db originaldb tablespace (multidata1,multiindex1,multiuser2)
schema(schema4,schema5) transport into targetdb
The transport
operation will fail and TARGETDB will remain unchanged because table
space multiuser2 already exists on the target database. SQLCODE=SQL2590N
rc=3.db2 restore db originaldb tablespace (myindex) schema(schema3)
transport into targetdb
The list of table spaces and
schemas being transported is not a valid transportable set. The transport
operation will fail and TARGETDB will remain unchanged. SQLCODE=SQL2590N
rc=1.db2 restore db originaldb tablespace (syscatspace) schema(sysibm)
transport into targetdb
The transport operation will
fail because the system catalogs can not be transported. SQLCODE=SQL2590N
rc=4. You can transport user defined table spaces or restore the system
catalogs with the RESTORE DATABASE command without specifying the
transport option.db2 restore db originaldb tablespace (mydata1) schema(schema1,schema2)
transport into notexists
The transport operation will
fail. Table spaces cannot be transported to a target database that
does not exist.