Professional Documents
Culture Documents
RMAN backup. This blog post explains how to do a restore of one table in a pluggable database.
Setup the test:
1.) Create a user – tables cannot be restored in the SYS schema
2.) Create a table for that user
3.) Take a backup – a backup of the table has to exist; it can’t just be in archive logs.
4.) Drop the table
5.) Restore the table
6.) Check that the table has been restored
1. Create a User
This user is being created in one pluggable database.
Tables cannot be restored in the SYS schema.
Alter session set container=PDB2
identified by "example"
profile default
account unlock
/
2. Create a Table
SQL> conn example/example@pdb2
Table created.
2 /
1 row created.
SQL> commit
2 /
Commit complete.
3. Take a Backup
You can’t restore a table that hasn’t been backed up, even if it exists in current archive logs.
$ rman target /
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights
reserved.
piece handle=/oradata/CDB2/arch/backup_25rmckbs_1_1
tag=TAG20161201T131332 comment=NONE
piece handle=/oradata/CDB2/arch/backup_26rmckbv_1_1
tag=TAG20161201T131335 comment=NONE
piece handle=/oradata/CDB2/arch/backup_27rmckd2_1_1
tag=TAG20161201T131335 comment=NONE
piece handle=/oradata/CDB2/arch/backup_28rmckdi_1_1
tag=TAG20161201T131335 comment=NONE
piece handle=/oradata/CDB2/arch/backup_29rmcke1_1_1
tag=TAG20161201T131335 comment=NONE
piece handle=/oradata/CDB2/arch/backup_2armckeg_1_1
tag=TAG20161201T131335 comment=NONE
piece handle=/oradata/CDB2/arch/backup_2brmckev_1_1
tag=TAG20161201T131511 comment=NONE
piece handle=/u01/app/oracle/product/12.1.0.2/dbs/c-600824249-
20161201-00 comment=NONE
RMAN> exit
2 /
Session altered.
COL1 NUMBER
SQL> /
Session altered.
2 /
COL1
----------
1
SYSDATE
-------------------
01-12-2016 17:17:21
2 /
Table dropped.
5. Restore the Table
This script will do a point in time, but you can also restore to an SCN, or to a sequence number.
run {
;
}
$ rman target /
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights
reserved.
RMAN>
RMAN> run {
Tablespace SYSTEM
Tablespace UNDOTBS1
db_name=CDB2
db_unique_name=zuao_pitr_PDB2_CDB2
compatible=12.1.0.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/oradata
_system_trig_enabled=FALSE
sga_target=1000M
processes=200
db_create_file_dest=/oradata/CDB2/aux
log_archive_dest_1='location=/oradata/CDB2/aux'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
output file
name=/oradata/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl
# restore the tablespaces in the recovery set and the auxiliary set
11 online";
12 online";
''/oradata/CDB2/aux/CDB2/controlfile/o1_mf_d40pzfbo_.ctl''
comment=
# mount database
database closed
database dismounted
# restore the tablespaces in the recovery set and the auxiliary set
database opened
}
executing Memory Script
TSPITR_DIROBJ_DPDIR as ''
/oradata/CDB2/aux''";
TSPITR_DIROBJ_DPDIR as ''
/oradata/CDB2/aux''";
EXPDP>
********************************************************************
**********
EXPDP> /oradata/CDB2/aux/tspitr_zuao_32949.dmp
Export completed
Import completed
RMAN>
6. Check that the table has been restored
SQL> alter session set container=PDB2
2 /
Session altered.
2 /
COL1
----------
1