Professional Documents
Culture Documents
Before starting to perform TSPITR, we should check the relationship between objects of the recovered
tablespace and objects of the different tablespaces which will not be recovered.
Make sure objects in the tablespace are self-contained.
Lets say we have the tablesapace called CRMS. It contains table TAB1 but indexes on that table
resides on another tablespace called HRMS. In this case, if you want to recover CRMS tablespace
to some point-in-time, then you must recover HRMS tablespace to the same point in time otherwise
you will lose indexes.
Lets start automatic TSPITR. I am NOT using recovery catalog.
CREATE TABLESPACES , USER , TABLE & INDEX
SYS> create tablespace crms datafile
'/u02/app/oracle/oradata/crms/crms01.dbf' size 100m;
Tablespace created.
SYS> alter tablespace crms add datafile
'/u02/app/oracle/oradata/crms/crms02.dbf' size 100m;
Tablespace altered.
SYS> create tablespace hrms datafile
'/u02/app/oracle/oradata/crms/hrms01.dbf' size 100m;
Tablespace created.
SYS> alter tablespace hrms add datafile
'/u02/app/oracle/oradata/crms/hrms02.dbf' size 100m;
Tablespace altered.
SYS> create user sony identified by sony default tablespace crms;
User created.
SYS> grant connect, resource to sony;
Grant succeeded.
SONY> create table tab1(id number , name varchar2(15), gender varchar2(6), salary number);
Table created.
SONY> alter table tab1 modify(id number constraint cons1_pkey primary key);
Table altered.
SONY> create index TAB1_GENDER_INDX1 on tab1(gender) tablespace hrms;
Index created.
SONY> select table_name, index_name, tablespace_name from
TABLE_NAME
-----------
INDEX_NAME
TABLESPACE_NAME
------------
----------------
TAB1
CONS1_PKEY
CRMS
TAB1
TAB1_GENDER_INDX1
HRMS
user_indexes;
piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_ncsnf_TAG20150412T
112644_bln2bbsp_.bkp tag=TAG20150412T112644 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-APR-15
Starting backup at 12-APR-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=71 RECID=444 STAMP=876828452
channel ORA_DISK_1: starting piece 1 at 12-APR-15
channel ORA_DISK_1: finished piece 1 at 12-APR-15
piece
handle=/u02/app/oracle/flash_recovery_area/CRMS/backupset/2015_04_12/o1_mf_annnn_TAG20150412T
112732_bln2bd6s_.bkp tag=TAG20150412T112732 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-APR-15
CREATE SOME TABLES IN SONY USER
SONY> create table tab2 as select * from tab1;
Table created.
SONY> create table tab3 as select * from tab1;
Table created.
SONY> create index tab3_gender_indx1 on tab3(gender) tablespace users;
Index created.
SONY> select index_name, table_name, tablespace_name from user_indexes;
INDEX_NAME
TABLE_NAME
TABLESPACE_NAME
TAB3
USERS
CONS1_PKEY
TAB1
CRMS
TAB1_GENDER_INDX1
TAB1
HRMS
TABLESPACE_NAME
------------------------------ -----------------------------TAB1
CRMS
TAB3
CRMS
TAB2
CRMS
TAB4
SYSTEM
292933632 bytes
1336092 bytes
Variable Size
100666596 bytes
Database Buffers
184549376 bytes
Redo Buffers
6381568 bytes
varchar2(512);
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
sqlstatement := 'alter tablespace '||
krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement);
exception
when offline_not_needed then
null;
end; >>>;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile
1 to new;
3 to new;
2 to new;
1 to new;
6 to
"/u02/app/oracle/oradata/crms/hrms01.dbf";
set newname for datafile
14 to
"/u02/app/oracle/oradata/crms/hrms02.dbf";
set newname for datafile
5 to
"/u02/app/oracle/oradata/crms/crms01.dbf";
set newname for datafile
7 to
"/u02/app/oracle/oradata/crms/crms02.dbf";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile
1, 3, 2, 6, 14, 5, 7;
1 online";
3 online";
2 online";
6 online";
14 online";
5 online";
7 online";
archivelog;
alter clone database open resetlogs;
}
1 online
3 online
2 online
6 online
14 online
5 online
7 online
/u01/tspitr_tjmt_40918.dmp
EXPDP> ******************************************************************************
EXPDP> Datafiles required for transportable tablespace CRMS:
EXPDP>
/u02/app/oracle/oradata/crms/crms01.dbf
EXPDP>
/u02/app/oracle/oradata/crms/crms02.dbf
/u02/app/oracle/oradata/crms/hrms01.dbf
EXPDP>
/u02/app/oracle/oradata/crms/hrms02.dbf
}
executing Memory Script
database closed
database dismounted
Oracle instance shut down
sql statement: drop tablespace
"CRMS" offline';
"HRMS" offline';
"CRMS" offline
"HRMS" offline
STATUS
------------------------------ --------SYSTEM
ONLINE
SYSAUX
ONLINE
UNDOTBS1
ONLINE
TEMP
ONLINE
USERS
ONLINE
CRMS
OFFLINE
HRMS
OFFLINE
7 rows selected.
MAKE TABLESPACES TO ONLINE
SYS> alter tablespace crms online;
Tablespace altered.
SYS> alter tablespace hrms online;
Tablespace altered.
SYS> conn sony/sony
Connected.
TABTYPE
CLUSTERID
TABLE
TAB2
TABLE
TAB3
TABLE
INDEX_NAME
----------------
TABLESPACE_NAME
----------------- ------------------
TAB1
CONS1_PKEY
CRMS
TAB1
TAB1_GENDER_INDX1
HRMS
Ckp Time
Name
Full 3943214
12-APR-15 /u02/app/oracle/oradata/crms/system01.dbf
Full 3943214
12-APR-15 /u02/app/oracle/oradata/crms/sysaux01.dbf
Full 3943214
12-APR-15 /u02/app/oracle/oradata/crms/undotbs01.dbf
Full 3943214
12-APR-15 /u02/app/oracle/oradata/crms/users01.dbf
Full 3943214
12-APR-15
Full 3943214
12-APR-15
Full 3943214
12-APR-15
14
Full 3943214
12-APR-15
Once we performed TSPITR, you must re-take backup of the recovered tablespaces.