30 March, 2012

The Hot Backup "myth" about Datafiles not being updated

This is an undying myth.  "datafiles are not updated when the database is in Hot Backup mode" .... "all updates are in the archivelogs and they are applied to the datafiles when the database is taken out of the Hot Backup mode" ... and so on ..

Here's an article by Jeremiah Wilton which has been refuting this myth for a very long time :
ORACLE TABLESPACE HOT BACKUP MODE REVISITED

.
.
.

24 March, 2012

Relocating a datafile using RMAN

RMAN can be used to relocate a datafile.

I start with the datafile present in /home/oracle/app/oracle/oradata/orcl/
SQL> select tablespace_name, file_id, file_name
  2  from dba_data_files 
  3  where file_name like '%add%';

TABLESPACE_NAME                   FILE_ID
------------------------------ ----------
FILE_NAME
--------------------------------------------------------------------------------
ADD_TBS                                14
/home/oracle/app/oracle/oradata/orcl/add_tbs.dbf


SQL> 
I would now like to relocate this to /oradata/orcl. I use RMAN thus :
RMAN> sql 'alter tablespace add_tbs offline'; 

using target database control file instead of recovery catalog
sql statement: alter tablespace add_tbs offline

RMAN> 
RMAN> copy datafile 14 to '/oradata/orcl/add_tbs_01.dbf';

Starting backup at 24-MAR-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00014 name=/home/oracle/app/oracle/oradata/orcl/add_tbs.dbf
output file name=/oradata/orcl/add_tbs_01.dbf tag=TAG20120324T001024 RECID=3 STAMP=778723826
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 24-MAR-12

RMAN>
RMAN> switch datafile 14 to copy;

datafile 14 switched to datafile copy "/oradata/orcl/add_tbs_01.dbf"

RMAN> recover tablespace add_tbs;

Starting recover at 24-MAR-12
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 24-MAR-12

RMAN> sql 'alter tablespace add_tbs online';

sql statement: alter tablespace add_tbs online

RMAN> 
That was easy -- so far.
Now ... the question is : If I do a LIST BACKUP, what appears as the location of the datafile ?  Is it /home/oacle/app/oracle/oradata/orcl  ? OR is it /oradata/orcl ?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Let's see ...........
.
.
.
.
.
.
.
.
.
.
RMAN> list backup of datafile 14;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8       Full    487.60M    DISK        00:01:12     01-JAN-12      
        BP Key: 8   Status: AVAILABLE  Compressed: YES  Tag: TAG20120101T112516
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp
  List of Datafiles in backup set 8
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  14      Full 4956816    01-JAN-12 /oradata/orcl/add_tbs_01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18      Full    530.30M    DISK        00:01:44     23-MAR-12      
        BP Key: 18   Status: AVAILABLE  Compressed: YES  Tag: TAG20120323T231454
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_03_23/o1_mf_nnndf_TAG20120323T231454_7ps4vgmf_.bkp
  List of Datafiles in backup set 18
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  14      Full 5192430    23-MAR-12 /oradata/orcl/add_tbs_01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21      Full    530.70M    DISK        00:01:23     23-MAR-12      
        BP Key: 21   Status: AVAILABLE  Compressed: YES  Tag: TAG20120323T235528
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_03_23/o1_mf_nnndf_TAG20120323T235528_7ps77jf2_.bkp
  List of Datafiles in backup set 21
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  14      Full 5194695    23-MAR-12 /oradata/orcl/add_tbs_01.dbf

RMAN> 
Apparently, Oracle now shows the *new* location of the datafile even for backups taken earlier !! How cool is that ?!

If I take a fresh backup ...
RMAN> backup datafile 14;

Starting backup at 24-MAR-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=/oradata/orcl/add_tbs_01.dbf
channel ORA_DISK_1: starting piece 1 at 24-MAR-12
channel ORA_DISK_1: finished piece 1 at 24-MAR-12
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_03_24/o1_mf_nnndf_TAG20120324T001527_7ps8dzm8_.bkp tag=TAG20120324T001527 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-MAR-12

RMAN> list backup of datafile 14;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8       Full    487.60M    DISK        00:01:12     01-JAN-12      
        BP Key: 8   Status: AVAILABLE  Compressed: YES  Tag: TAG20120101T112516
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_01_01/o1_mf_nnndf_TAG20120101T112516_7hznjx24_.bkp
  List of Datafiles in backup set 8
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  14      Full 4956816    01-JAN-12 /oradata/orcl/add_tbs_01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18      Full    530.30M    DISK        00:01:44     23-MAR-12      
        BP Key: 18   Status: AVAILABLE  Compressed: YES  Tag: TAG20120323T231454
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_03_23/o1_mf_nnndf_TAG20120323T231454_7ps4vgmf_.bkp
  List of Datafiles in backup set 18
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  14      Full 5192430    23-MAR-12 /oradata/orcl/add_tbs_01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21      Full    530.70M    DISK        00:01:23     23-MAR-12      
        BP Key: 21   Status: AVAILABLE  Compressed: YES  Tag: TAG20120323T235528
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_03_23/o1_mf_nnndf_TAG20120323T235528_7ps77jf2_.bkp
  List of Datafiles in backup set 21
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  14      Full 5194695    23-MAR-12 /oradata/orcl/add_tbs_01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
24      Full    1.23M      DISK        00:00:00     24-MAR-12      
        BP Key: 24   Status: AVAILABLE  Compressed: NO  Tag: TAG20120324T001527
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_03_24/o1_mf_nnndf_TAG20120324T001527_7ps8dzm8_.bkp
  List of Datafiles in backup set 24
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  14      Full 5196666    24-MAR-12 /oradata/orcl/add_tbs_01.dbf

RMAN> 
Yes, BackupSet Key 24 has the latest backup, created today.

Today's question :
What is the information that Oracle stores ?  If the location of datafile 14 was under /home/oracle/app/oracle/oradata/orcl  on 01-Jan and 23-Mar, why isn't that location  presented ?Is it not stored in the repository ?  Yes, the location of the BackupPiece is evident, but the location of the datafile is "current" even when the backup was taken when the datafile was elsewhere !

.
.
.

20 March, 2012

More than 250K page views

My Oracle DBA Blog has achieved more than 250K page views in less than 3 years.


10 March, 2012

Oracle Database Performance Diagnostics -- before you begin

I have published, on my own site, an article 'Oracle Database "Performance diagnostics" : Before you begin'.  This was an article that I had submitted to OTN in 2011 but was, apparently, not published there.

I hope that you find it useful.

.
.
.

06 March, 2012

Another example of COST in an Explain Plan

Jonathan Lewis has identified a seemingly simple example of a COUNT(*) query that can be written in two manners, has the same COST in an Explain Plan (although the Plan is different) and yet has very different actual performance characteristics.
(See Tom Kyte's explanation of how the two queries actual perform differently).
.
.
.

03 March, 2012

Packt Publishing's Oracle Packtpot


Packt is launching a program "Oracle Packtpot: Exciting discounts on Oracle books/e-books" throughout March2012!

.
.
.