Complete Recovery With RMAN Backup.
BACKUP AND RECOVERY SCENARIOS Complete Recovery With RMAN
Backup.
previous post i have posted a complete recovery with user-managed backup,
here we are going to see the complete recovery using rman backup.
you can perform complete recovery in the following 5 situations.
RMAN Recovery Scenarios of complete recovery.
1. Complete Closed Database Recovery. System datafile is missing
2. Complete Open Database Recovery. Non system datafile is missing
3. Complete Open Database Recovery (when the database is initially closed).
Non system datafile is missing
4. Recovery of a Datafile that has no backups.
5. Restore and Recovery of a Datafile to a different location.
1.Complete Closed Database Recovery. System Datafile is missing
In this case complete recovery is performed, only the system datafile is
missing,
so the database can be opened without reseting the redologs.
1. rman target /
2. startup mount;
3. restore database or datafile file#;
4. recover database or datafile file#;
5. alter database open;
workshop1:
view plaincopy to clipboardprint?
1. SQL> create user sweety identified by sweety;
2.
3. User created.
4.
5. SQL> grant dba to sweety;
6.
7. Grant succeeded.
8.
9. SQL> shu immediate
10. Database closed.
11. Database dismounted.
12. ORACLE instance shut down.
13. SQL> host rm -rf /u01/app/oracle/oradata/testdb/system01.dbf
14.
15. SQL> startup
16. ORACLE instance started.
17.
18. Total System Global Area 444596224 bytes
19. Fixed Size 1219904 bytes
20. Variable Size 130024128 bytes
21. Database Buffers 310378496 bytes
22. Redo Buffers 2973696 bytes
23. Database mounted.
24. ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
25. ORA-01110: data file 1: '/u01/app/oracle/oradata/testdb/system01.dbf'
26.
27.
28. SQL> shutdown immediate
29. ORA-01109: database not open
30.
31.
32. Database dismounted.
33. ORACLE instance shut down.
34. SQL>
35.
36. [oracle@cdbs1 ~]$ rman target /
37.
38. Recovery Manager: Release 10.2.0.1.0 - Production on Fri May 7 23:53:51 2010
39.
40. Copyright (c) 1982, 2005, Oracle. All rights reserved.
41.
42. connected to target database (not started)
43.
44. RMAN> startup mount
45.
46. Oracle instance started
47. database mounted
48.
49. Total System Global Area 444596224 bytes
50.
51. Fixed Size 1219904 bytes
52. Variable Size 130024128 bytes
53. Database Buffers 310378496 bytes
54. Redo Buffers 2973696 bytes
55.
56. RMAN> RESTORE DATABASE;
57.
58. Starting restore at 07-MAY-10
59. using target database control file instead of recovery catalog
60. allocated channel: ORA_DISK_1
61. channel ORA_DISK_1: sid=156 devtype=DISK
62.
63. channel ORA_DISK_1: starting datafile backupset restore
64. channel ORA_DISK_1: specifying datafile(s) to restore from backup set
65. restoring datafile 00001 to /u01/app/oracle/oradata/testdb/system01.dbf
66. restoring datafile 00002 to /u01/app/oracle/oradata/testdb/undotbs01.dbf
67. restoring datafile 00003 to /u01/app/oracle/oradata/testdb/sysaux01.dbf
68. restoring datafile 00004 to /u01/app/oracle/oradata/testdb/users01.dbf
69. restoring datafile 00005 to /u03/oradata/test01.dbf
70. channel ORA_DISK_1: reading from backup piece /u01/app/oracle/
flash_recovery_area/TESTDB/backupset/2010_05_07/
o1_mf_nnndf_TAG20100507T232259_5y8nvxt2_.bkp
71. channel ORA_DISK_1: restored backup piece 1
72. piece handle=/u01/app/oracle/flash_recovery_area/TESTDB/backupset/2010_05_07/
o1_mf_nnndf_TAG20100507T232259_5y8nvxt2_.bkp tag=TAG20100507T232259
73. channel ORA_DISK_1: restore complete, elapsed time: 00:02:52
74. Finished restore at 07-MAY-10
75.
76. RMAN> RECOVER DATABASE;
77.
78. Starting recover at 07-MAY-10
79. using channel ORA_DISK_1
80.
81. starting media recovery
82.
83.
84. RMAN> sql 'alter database open';
85.
86. sql statement: alter database open
87.
88. RMAN>
89. SQL> conn sys/oracle as sysdba;
90. Connected.
91. SQL> col name format a45
92. SQL> select name , status from v$datafile;
93.
94. NAME STATUS
95. --------------------------------------------- -------
96. /u01/app/oracle/oradata/testdb/system01.dbf SYSTEM
97. /u01/app/oracle/oradata/testdb/undotbs01.dbf ONLINE
98. /u01/app/oracle/oradata/testdb/sysaux01.dbf ONLINE
99. /u01/app/oracle/oradata/testdb/users01.dbf ONLINE
100. /u03/oradata/test01.dbf ONLINE
101.
102. SQL> select username from dba_users
103. 2 where username='SWEETY';
104.
105. USERNAME
106. ------------------------------
107. SWEETY
2.Complete Open Database Recovery. Non system datafile is missing,
database is up
1. rman target /
2. sql 'alter tablespace offline immediate';
or
sql 'alter database datafile file# offline;
3. restore datafile 3;
4. recover datafile 3;
5. sql 'alter tablespace online';
or
sql 'alter database datafile file# online;
workshop2:
view plaincopy to clipboardprint?
1. SQL> conn sweety/sweety;
2. Connected.
3. SQL> create table demo(id number);
4.
5. Table created.
6.
7. SQL> insert into demo values(123);
8.
9. 1 row created.
10.
11. SQL> commit;
12.
13. Commit complete.
14.
15. SQL> conn sys/oracle as sysdba;
16. Connected.
17. SQL> select username,default_tablespace from dba_users 2 where username='SWEE
TY';
18.
19. USERNAME DEFAULT_TABLESPACE
20. ------------------------------ ------------------------------
21. SWEETY USERS
22.
23. SQL> host rm -rf /u01/app/oracle/oradata/testdb/users01.dbf
24.
25. SQL> conn sweety/sweety
26. Connected.
27. SQL> alter system flush buffer_cache;
28.
29. System altered.
30.
31. SQL> select * from demo;
32. select * from demo
33. *
34. ERROR at line 1:
35. ORA-01116: error in opening database file 4
36. ORA-01110: data file 4: '/u01/app/oracle/oradata/testdb/users01.dbf'
37. ORA-27041: unable to open file
38. Linux Error: 2: No such file or directory
39. Additional information: 3
40.
41. [oracle@cdbs1 ~]$ rman target /
42.
43. Recovery Manager: Release 10.2.0.1.0 - Production on Sat May 8 01:35:09 2010
44.
45. Copyright (c) 1982, 2005, Oracle. All rights reserved.
46.
47. connected to target database: TESTDB (DBID=2501713962)
48.
49. RMAN> sql 'alter database datafile 4 offline';
50.
51. using target database control file instead of recovery catalog
52. sql statement: alter database datafile 4 offline
53.
54. RMAN> restore datafile 4;
55.
56. Starting restore at 08-MAY-10
57. using channel ORA_DISK_1
58. ...
59. channel ORA_DISK_1: restore complete, elapsed time: 00:00:09
60. Finished restore at 08-MAY-10
61.
62. RMAN> recover datafile 4;
63.
64. Starting recover at 08-MAY-10
65. using channel ORA_DISK_1
66.
67. starting media recovery
68. ......
69. media recovery complete, elapsed time: 00:00:05
70. Finished recover at 08-MAY-10
71.
72. RMAN> sql 'alter database datafile 4 online';
73.
74. sql statement: alter database datafile 4 online
75.
76. RMAN>exit
77.
78. SQL> conn sweety/sweety;
79. Connected.
80. SQL> select * from demo;
81.
82. ID
83. ----------
84. 123
85.
86. SQL>
3.Complete Open Database Recovery (when the database is initially
closed).
Non system datafile is missing
A user datafile is reported missing when trying to startup the database. The
datafile can be turned offline and the database started up. Restore and
recovery are performed using Rman. After recovery is performed the datafile
can be turned online again.
1. sqlplus /nolog
2. connect / as sysdba
3. startup mount
4. alter database datafile '' offline;
5. alter database open;
6. exit;
7. rman target /
8. restore datafile '';
9. recover datafile '';
10. sql 'alter tablespace online';
workshop3:
view plaincopy to clipboardprint?
1. SQL> conn sweety/sweety;
2. Connected.
3.
4. SQL> create table test ( testid number);
5.
6. Table created.
7.
8. SQL> insert into test values(54321);
9.
10. 1 row created.
11.
12. SQL> commit;
13.
14. Commit complete.
15.
16. SQL> conn sys/oracle as sysdba;
17. Connected.
18. SQL>shu immediate
19. SQL> host rm -rf /u01/app/oracle/oradata/testdb/users01.dbf
20.
21. SQL> startup
22. ORACLE instance started.
23.
24. Total System Global Area 444596224 bytes
25. Fixed Size 1219904 bytes
26. Variable Size 138412736 bytes
27. Database Buffers 301989888 bytes
28. Redo Buffers 2973696 bytes
29. Database mounted.
30. ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
31. ORA-01110: data file 4: '/u01/app/oracle/oradata/testdb/users01.dbf'
32.
33. SQL> alter database datafile 4 offline;
34.
35. Database altered.
36.
37. SQL> alter database open;
38.
39. Database altered.
40.
41. [oracle@cdbs1 ~]$ rman target /
42.
43. Recovery Manager: Release 10.2.0.1.0 - Production on Sat May 8 01:51:45 2010
44.
45. Copyright (c) 1982, 2005, Oracle. All rights reserved.
46.
47. connected to target database: TESTDB (DBID=2501713962)
48.
49. RMAN> restore datafile 4;
50.
51. Starting restore at 08-MAY-10
52. using target database control file instead of recovery catalog
53. .....
54. channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
55. Finished restore at 08-MAY-10
56.
57. RMAN> recover datafile 4;
58.
59. Starting recover at 08-MAY-10
60. using channel ORA_DISK_1
61.
62. starting media recovery
63. .....
64. media recovery complete, elapsed time: 00:00:08
65. Finished recover at 08-MAY-10
66.
67. RMAN> exit
68.
69. SQL> alter database datafile 4 online;
70.
71. Database altered.
72.
73. SQL> conn sweety/sweety;
74. Connected.
75. SQL> select * from test;
76.
77. TESTID
78. ----------
79. 54321
4.Recovery of a Datafile that has no backups (database is up).
If a non system datafile that was not backed up since the last backup is missing,
recovery can be performed if all archived logs since the creation
of the missing datafile exist. Since the database is up you can check the
tablespace name and put it offline. The option offline immediate is used
to avoid that the update of the datafile header.
Pre requisites: All relevant archived logs.
1. sqlplus '/ as sysdba'
2. alter tablespace offline immediate;
3. alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf;
4. exit
5. rman target /
6. recover tablespace ;
7. sql 'alter tablespace online';
If the create datafile command needs to be executed to place the datafile on a
location different than the original use:
alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf' as
'/user/oradata/u02/dbtst/newdata01.dbf'
restriction: controlfile creation time must be prior than datafile creation time.
for more reference refer previous blog post.(user-managed complete recovery).
workshop4:
view plaincopy to clipboardprint?
1. SQL> create user john identified by john
2. 2 default tablespace testing;
3.
4. User created.
5.
6. SQL> grant dba to john;
7.
8. Grant succeeded.
9.
10. SQL> conn john/john;
11. Connected.
12. SQL> create table test_tb( testid number);
13.
14. Table created.
15.
16. SQL> insert into test_tb values(1001);
17.
18. 1 row created.
19.
20. SQL> commit;
21.
22. Commit complete.
23.
24. SQL> select * from test_tb;
25.
26. TESTID
27. ----------
28. 1001
29.
30. SQL> conn sys/oracle as sysdba;
31. Connected.
32. SQL> host rm -rf /u03/oradata/test01.dbf
33.
34. SQL> alter system flush buffer_cache;
35.
36. System altered.
37.
38. SQL> conn john/john;
39. Connected.
40. SQL> select * from test_tb;
41. select * from test_tb
42. *
43. ERROR at line 1:
44. ORA-01116: error in opening database file 5
45. ORA-01110: data file 5: '/u03/oradata/test01.dbf'
46. ORA-27041: unable to open file
47. Linux Error: 2: No such file or directory
48. Additional information: 3
49. SQL> conn sys/oracle as sysdba;
50. Connected.
51. SQL> alter tablespace testing offline immediate;
52.
53. Tablespace altered.
54. ---if you want to create datafile in same location
55. SQL> alter database create datafile '/u03/oradata/test01.dbf';
56.
57. Database altered.
58. ---if you want to create a datafile in different location(disk).
59. SQL> alter database create datafile '/u03/oradata/test01.dbf' as '/u01/app/
oracle/oradata/testdb/test01.dbf';
60.
61. Database altered.
62. [oracle@cdbs1 ~]$ rman target /
63.
64. Recovery Manager: Release 10.2.0.1.0 - Production on Sat May 8 02:15:28 2010
65.
66. Copyright (c) 1982, 2005, Oracle. All rights reserved.
67.
68. connected to target database: TESTDB (DBID=2501713962)
69.
70. RMAN> recover tablespace testing;
71.
72. Starting recover at 08-MAY-10
73. using target database control file instead of recovery catalog
74. allocated channel: ORA_DISK_1
75. channel ORA_DISK_1: sid=145 devtype=DISK
76.
77. starting media recovery
78.
79. SQL> alter tablespace testing online;
80.
81. Tablespace altered.
82.
83. SQL> conn john/john;
84. Connected.
85. SQL> select * from test_tb;
86.
87. TESTID
88. ----------
89. 1001
5.Restore and Recovery of a Datafile to a different location. Database
is up.
If a non system datafile is missing and its original location not available, restore
can be made to a different location and recovery performed.
Pre requisites: All relevant archived logs, complete cold or hot backup.
1. Use OS commands to restore the missing or corrupted datafile to the new
location, ie:
cp -p /user/backup/uman/user01.dbf /user/oradata/u02/dbtst/user01.dbf
2. alter tablespace offline immediate;
3. alter tablespace rename datafile
'/user/oradata/u01/dbtst/user01.dbf' to '/user/oradata/u02/dbtst/user01.dbf';
4. rman target /
5. recover tablespace ;
6. sql 'alter tablespace online';
workshop5:
follow the same example workshop4 for workshop 5 except creating new
datafile, here you have to copy the recent backup file to the new disk location
and perform recovery. thats it , rest of the procedures are same.
regards,
Rajeshkumar Govindarajan.
POSTED BY RAJESHKUMAR GOVINDARAJAN AT SATURDAY, MAY 08, 2010 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS, BACKUP AND RECOVERY, RMAN
FRIDAY, MAY 7, 2010
Complete Recovery With User-managed Backup with
Examples
BACKUP AND RECOVERY SCENARIOS
Complete Recovery With User-managed Backup.
you can perform complete recovery in the below 5 situations.
User Managed Recovery Scenarios of complete recovery.
1. Complete Closed Database Recovery. System datafile is missing(with recent
backups)
2. Complete Open Database Recovery. Non system datafile is missing(with
backups).
3. Complete Open Database Recovery (when the database is initially closed).
Non system datafile is missing(with backups)
4. Recovery of a Missing Datafile that has no backups.(Disk corrupted and no
backups available)
restriction: datafile should be created after controlfile creation.(i.e,controlfile
creation time is prior than datafile creation time).
you cannot recover or create datafile without backup in the following situation:
view plaincopy to clipboardprint?
1. SQL> select CONTROLFILE_CREATED from v$database;
2. CONTROLFILE_CREATED
3. --------------------
4. 07-MAY-2010 01:23:43
view plaincopy to clipboardprint?
1. SQL> select creation_time,name from v$datafile;
2. CREATION_TIME NAME
3. -------------------- ---------------------------------------------
4. 30-JUN-2005 19:10:11 /u01/app/oracle/oradata/testdb/system01.dbf
5. 30-JUN-2005 19:55:01 /u01/app/oracle/oradata/testdb/undotbs01.dbf
6. 30-JUN-2005 19:10:27 /u01/app/oracle/oradata/testdb/sysaux01.dbf
7. 30-JUN-2005 19:10:40 /u01/app/oracle/oradata/testdb/users01.dbf
5. Restore and Recovery of a Datafile to a different location.(Disk corrupted
having recent backup and recover the datafile in new Disk location).
User Managed Recovery Scenarios
User managed recovery scenarios do require that the database is in archive log
mode, and that backups of all datafiles and control files are made with the
tablespaces set to begin backup, if the database is open while the copy is made.
At the end of the copy of each tablespace it is necessaire to take it out of
backup mode. Alternatively complete backups can be made with the database
shutdown. Online redologs can be optionally backed up.
Files to be copied:
select name from v$datafile;
select member from v$logfile; # optional
select name from v$controlfile;
1.Complete Closed Database Recovery. System tablespace is missing
If the system tablespace is missing or corrupted the database cannot be
started up
so a complete closed database recovery must be performed.
Pre requisites: A closed or open database backup and archived logs.
1. Use OS commands to restore the missing or corrupted system datafile to
its original location from recent backup, ie:
cp -p /user/backup/uman/system01.dbf
/user/oradata/u01/dbtst/system01.dbf
2. startup mount;
3. recover datafile 1;
4. alter database open;
workshop1: system datafile recovery with recent backup
view plaincopy to clipboardprint?
1. SQL> create user rajesh identified by rajesh;
2. User created.
3. SQL> grant dba to rajesh;
4. Grant succeeded.
5. SQL> shutdown immediate
6. Database closed.
7. Database dismounted.
8. ORACLE instance shut down.
9. i manually deleted the datafile system01.dbf for testing purpose only
10. SQL> startup
11. ORACLE instance started.
12. Total System Global Area 444596224 bytes
13. Fixed Size 1219904 bytes
14. Variable Size 138412736 bytes
15. Database Buffers 301989888 bytes
16. Redo Buffers 2973696 bytes
17. Database mounted.
18. ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
19. ORA-01110: data file 1: '/u01/app/oracle/oradata/testdb/system01.dbf'
20.
21.
22. SQL> shutdown immediate
23. ORA-01109: database not open
24.
25.
26. Database dismounted.
27. ORACLE instance shut down.
28. SQL> host cp /u01/app/oracle/oradata/backup/system01.dbf /u01/app/oracle/
oradata/testdb/system01.dbf
29. system datafile restored from recent backup
30.
31. SQL*Plus: Release 10.2.0.1.0 - Production on Fri May 7 12:51:16 2010
32.
33. Copyright (c) 1982, 2005, Oracle. All rights reserved.
34.
35. Enter user-name: sys as sysdba
36. Enter password:
37. Connected to an idle instance.
38.
39. SQL> startup mount
40. ORACLE instance started.
41.
42. Total System Global Area 444596224 bytes
43. Fixed Size 1219904 bytes
44. Variable Size 138412736 bytes
45. Database Buffers 301989888 bytes
46. Redo Buffers 2973696 bytes
47. Database mounted.
48. SQL> recover datafile 1;
49. ORA-00279: change 454383 generated at 05/07/2010 01:40:11 needed for thread 1
50. ORA-00289: suggestion :
51. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_7_
%u_.arc
52. ORA-00280: change 454383 for thread 1 is in sequence #7
53.
54.
55. Specify log: {=suggested | filename | AUTO | CANCEL}
56. auto
57. ORA-00279: change 456007 generated at 05/07/2010 12:46:10 needed for thread 1
58. ORA-00289: suggestion :
59. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_8_
%u_.arc
60. ORA-00280: change 456007 for thread 1 is in sequence #8
61. ORA-00278: log file
62. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_7_5y7hkty0_.arc' no longer needed for this recovery
63. .
64. .
65. .
66. ORA-00279: change 456039 generated at 05/07/2010 12:46:22 needed for thread 1
67. ORA-00289: suggestion :
68. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_11_
%u_.arc
69. ORA-00280: change 456039 for thread 1 is in sequence #11
70. ORA-00278: log file
71. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_10_5y7hl7dr_.arc' no longer needed for this recovery
72.
73.
74. Log applied.
75. Media recovery complete.
76. SQL> alter database open;
77.
78. Database altered.
79.
80. SQL> archive log list;
81. Database log mode Archive Mode
82. Automatic archival Enabled
83. Archive destination USE_DB_RECOVERY_FILE_DEST
84. Oldest online log sequence 12
85. Next log sequence to archive 14
86. Current log sequence 14
87. SQL> select username from dba_users
88. 2 where username='RAJESH';
89.
90. USERNAME
91. ------------------------------
92. RAJESH
2.Complete Open Database Recovery. Non system tablespace is
missing
If a non system tablespace is missing or corrupted while the database is
open, recovery can be performed while the database remain open.
Pre requisites: A closed or open database backup and archived logs.
1. Use OS commands to restore the missing or corrupted datafile to its
original location, ie:
cp -p /user/backup/uman/user01.dbf /user/oradata/u01/dbtst/user01.dbf
2. alter tablespace offline immediate;
3. recover tablespace ;
4. alter tablespace online;
workshop2: Non-system datafile recovery from recent backup when database is open
view plaincopy to clipboardprint?
1. SQL> ALTER USER rajesh DEFAULT TABLESPACE users;
2.
3. User altered.
4.
5. SQL> conn rajesh/rajesh;
6. Connected.
7. SQL> create table demo(id number);
8.
9. Table created.
10.
11. SQL> insert into demo values(123);
12.
13. 1 row created.
14.
15. SQL> commit;
16.
17. Commit complete.
18.
19. SQL> select * from demo;
20.
21. ID
22. ----------
23. 123
24.
25. SQL> conn sys/oracle as sysdba;
26. Connected.
27. SQL> alter system switch logfile;
28.
29. System altered.
30.
31. SQL> /
32.
33. System altered.
34.
35. SQL> archive log list;
36. Database log mode Archive Mode
37. Automatic archival Enabled
38. Archive destination USE_DB_RECOVERY_FILE_DEST
39. Oldest online log sequence 14
40. Next log sequence to archive 16
41. Current log sequence 16
42. i manually deleted the datafile users01.dbf for testing purpose only
43. SQL> conn rajesh/rajesh;
44. Connected.
45. SQL> alter system flush buffer_cache;
46.
47. System altered.
48.
49. SQL> select * from demo;
50. select * from demo
51. *
52. ERROR at line 1:
53. ORA-00376: file 4 cannot be read at this time
54. ORA-01110: data file 4: '/u01/app/oracle/oradata/testdb/users01.dbf'
55.
56.
57. SQL> conn sys/oracle as sysdba;
58. Connected.
59. SQL> host cp -p /u01/app/oracle/oradata/backup/users01.dbf /u01/app/oracle/
oradata/testdb/users01.dbf
60. restore the users01.dbf datafile from recent backup to the testdb folder
61.
62. SQL> alter tablespace users offline immediate;
63.
64. Tablespace altered.
65.
66. SQL> recover tablespace users;
67. ORA-00279: change 454383 generated at 05/07/2010 01:40:11 needed for thread 1
68. ORA-00289: suggestion :
69. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_7_
%u_.arc
70. ORA-00280: change 454383 for thread 1 is in sequence #7
71.
72.
73. Specify log: {=suggested | filename | AUTO | CANCEL}
74. auto
75. ORA-00279: change 456007 generated at 05/07/2010 12:46:10 needed for thread 1
76. ORA-00289: suggestion :
77. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_8_
%u_.arc
78. ORA-00280: change 456007 for thread 1 is in sequence #8
79. ORA-00278: log file
80. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_7_5y7hkty0_.arc' no longer needed for this recovery
81. .....
82. ......
83. ORA-00279: change 456044 generated at 05/07/2010 12:46:28 needed for thread 1
84. ORA-00289: suggestion :
85. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_13_
%u_.arc
86. ORA-00280: change 456044 for thread 1 is in sequence #13
87. ORA-00278: log file
88. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_12_5y7hldl2_.arc' no longer needed for this recovery
89.
90.
91. Log applied.
92. Media recovery complete.
93. SQL> alter tablespace users online;
94.
95. Tablespace altered.
96.
97. SQL> conn rajesh/rajesh;
98. Connected.
99. SQL> select * from demo;
100.
101. ID
102. ----------
103. 123
3.Complete Open Database Recovery (when the database is initially
closed).Non system datafile is missing
If a non system tablespace is missing or corrupted and the database crashed,
recovery can be performed after the database is open.
Pre requisites: A closed or open database backup and archived logs.
1. startup; (you will get ora-1157 ora-1110 and the name of the missing
datafile, the database will remain mounted)
2. alter database datafile3 offline; (tablespace cannot be used because the
database is not open)
3. alter database open;
4. Use OS commands to restore the missing or corrupted datafile to its original
location, ie:
cp -p /user/backup/uman/user01.dbf /user/oradata/u01/dbtst/user01.dbf
5. recover datafile 3;
6. alter tablespace online;
workshop 3:Non system datafile is missing
view plaincopy to clipboardprint?
1. SQL> conn sys/oracle as sysdba;
2. Connected.
3. SQL> alter system switch logfile;
4.
5. System altered.
6.
7. SQL> select username,default_tablespace from dba_users
8. 2 where username='RAJESH';
9.
10. USERNAME DEFAULT_TABLESPACE
11. ------------------------------ ------------------------------
12. RAJESH USERS
13.
14. SQL> conn rajesh/rajesh;
15. Connected.
16. SQL> create table testtbl (id number);
17.
18. Table created.
19.
20. SQL> insert into testtbl values(786);
21.
22. 1 row created.
23.
24. SQL> commit;
25.
26. Commit complete.
27.
28. SQL> select * from testtbl;
29.
30. ID
31. ----------
32. 786
33.
34. SQL> conn sys/oracle as sysdba;
35. Connected.
36. SQL> shutdown immediate;
37. Database closed.
38. Database dismounted.
39. ORACLE instance shut down.
40. SQL> --manually deleting the users01.dbf datafile from testdb folder
41. warning:for testing purpose only
42. SQL> host rm -rf /u01/app/oracle/oradata/testdb/users01.dbf
43.
44. SQL> startup
45. ORACLE instance started.
46.
47. Total System Global Area 444596224 bytes
48. Fixed Size 1219904 bytes
49. Variable Size 142607040 bytes
50. Database Buffers 297795584 bytes
51. Redo Buffers 2973696 bytes
52. Database mounted.
53. ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
54. ORA-01110: data file 4: '/u01/app/oracle/oradata/testdb/users01.dbf'
55.
56.
57. SQL> alter database datafile 4 offline;
58.
59. Database altered.
60.
61. SQL> alter database open;
62.
63. Database altered.
64.
65. SQL> host cp -p /u01/app/oracle/oradata/backup/users01.dbf /u01/app/oracle/
oradata/testdb/users01.dbf
66. copying user01.dbf from the recent backup to the testdb folder
67. SQL> recover datafile 4;
68. ORA-00279: change 454383 generated at 05/07/2010 01:40:11 needed for thread 1
69. ORA-00289: suggestion :
70. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_7_
%u_.arc
71. ORA-00280: change 454383 for thread 1 is in sequence #7
72.
73.
74. Specify log: { =suggested | filename | AUTO | CANCEL} auto
75. ORA-00279: change 456007 generated at 05/07/2010 12:46:10 needed for thread 1
76. ORA-00289: suggestion :
77. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_8_
%u_.arc
78. ORA-00280: change 456007 for thread 1 is in sequence #8
79. ORA-00278: log file
80. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_7_5y7hkty0_.arc' no longer needed for this recovery
81. ......
82. .........
83. ORA-00279: change 456046 generated at 05/07/2010 12:46:29 needed for thread 1
84. ORA-00289: suggestion :
85. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_14_
%u_.arc
86. ORA-00280: change 456046 for thread 1 is in sequence #14
87. ORA-00278: log file
88. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_13_5y7hlfbc_.arc' no longer needed for this recovery
89.
90.
91. Log applied.
92. Media recovery complete.
93. SQL> alter database datafile 4 online;
94.
95. Database altered.
96.
97. SQL> conn rajesh/rajesh;
98. Connected.
99. SQL> select * from testtbl;
100.
101. ID
102. ----------
103. 786
4.Recovery of a Missing Datafile that has no backups (database is
open).
If a non system datafile that was not backed up since the last backup is missing,
recovery can be performed if all archived logs since the creation
of the missing datafile exist.
Pre requisites: All relevant archived logs.
1. alter tablespace offline immediate;
2. alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf';
3. recover tablespace ;
4. alter tablespace online;
If the create datafile command needs to be executed to place the datafile on a
location different than the original use:
alter database create datafile '/user/oradata/u01/dbtst/newdata01.dbf' as
'/user/oradata/u02/dbtst/newdata01.dbf'
restriction: datafile should be created after controlfile creation.(i.e,controlfile
creation time is prior than datafile creation time).
workshop 4: Missing Non-system Datafile having no backups
view plaincopy to clipboardprint?
1. SQL> alter session set nls_date_format='DD-MON-YYYY hh24:mi:ss';
2.
3. Session altered.
4.
5. SQL> select controlfile_created from v$database;
6.
7. CONTROLFILE_CREATED
8. --------------------
9. 07-MAY-2010 16:27:22
10.
11. SQL> col name format a45
12. SQL> select creation_time,name from v$datafile;
13.
14. CREATION_TIME NAME
15. -------------------- ---------------------------------------------
16. 30-JUN-2005 19:10:11 /u01/app/oracle/oradata/testdb/system01.dbf
17. 30-JUN-2005 19:55:01 /u01/app/oracle/oradata/testdb/undotbs01.dbf
18. 30-JUN-2005 19:10:27 /u01/app/oracle/oradata/testdb/sysaux01.dbf
19. 30-JUN-2005 19:10:40 /u01/app/oracle/oradata/testdb/users01.dbf
20. you cannot re-create the any one of the listed above datafile , without backup.
21. SQL> create tablespace testing datafile
22. 2 '/u01/app/oracle/oradata/testdb/test01.dbf' size 2m;
23.
24. Tablespace created.
25.
26. SQL> select creation_time,name from v$datafile;
27.
28. CREATION_TIME NAME
29. -------------------- ---------------------------------------------
30. 30-JUN-2005 19:10:11 /u01/app/oracle/oradata/testdb/system01.dbf
31. 30-JUN-2005 19:55:01 /u01/app/oracle/oradata/testdb/undotbs01.dbf
32. 30-JUN-2005 19:10:27 /u01/app/oracle/oradata/testdb/sysaux01.dbf
33. 30-JUN-2005 19:10:40 /u01/app/oracle/oradata/testdb/users01.dbf
34. 07-MAY-2010 16:32:07 /u01/app/oracle/oradata/testdb/test01.dbf
35. we can re-create test01.dbf file without backup.
36. SQL> select controlfile_created from v$database;
37.
38. CONTROLFILE_CREATED
39. --------------------
40. 07-MAY-2010 16:27:22
41.
42. ---we can recover the datafile test01.dbf without backup using
view plaincopy to clipboardprint?
1. create datafile command in recovery
2. ---in this example i am going to create a table in testing tablespace
view plaincopy to clipboardprint?
1. and deleted the test01.dbf datafile and recover it without backup and
view plaincopy to clipboardprint?
1. create datafile recovery command.
2.
3. SQL> create user jay identified by jay
4. 2 default tablespace testing;
5.
6. User created.
7.
8. SQL> grant dba to jay;
9.
10. Grant succeeded.
11.
12. SQL> select username,default_tablespace from dba_users
13. 2 where username='JAY';
14.
15. USERNAME DEFAULT_TABLESPACE
16. ------------------------------ ------------------------------
17. JAY TESTING
18.
19. SQL> conn jay/jay;
20. Connected.
21. SQL> create table demo (id number);
22.
23. Table created.
24.
25. SQL> insert into demo values(321);
26.
27. 1 row created.
28.
29. SQL> commit;
30.
31. Commit complete.
32.
33. SQL> select * from demo;
34.
35. ID
36. ----------
37. 321
38.
39. SQL> conn sys/oracle as sysdba;
40. Connected.
41. SQL> host rm -rf /u01/app/oracle/oradata/testdb/test01.dbf
42. ---manually deleting datafile test01.dbf for testing purpose
43.
44. SQL> conn jay/jay;
45. Connected.
46. SQL> select * from demo;
47.
48. ID
49. ----------
50. 321
51.
52. SQL> alter system flush buffer_cache;
53.
54. System altered.
55.
56. SQL> select * from demo;
57. select * from demo
58. *
59. ERROR at line 1:
60. ORA-01116: error in opening database file 5
61. ORA-01110: data file 5: '/u01/app/oracle/oradata/testdb/test01.dbf'
62. ORA-27041: unable to open file
63. Linux Error: 2: No such file or directory
64. Additional information: 3
65.
66.
67. SQL> alter database datafile 5 offline;
68.
69. Database altered.
70. ----TO CREATE A NEW RECOVERED DATAFILE IN SAME LOCATION.
71. SQL> alter database create datafile '/u01/app/oracle/oradata/testdb/test01.dbf';
72. Database altered.
73. ----TO CREATE A NEW RECOVERED DATAFILE IN DIFFERENT LOCATION.
74. SQL> alter database create datafile '/u01/app/oracle/oradata/testdb/test01.dbf'
as '/u03/oradata/test01.dbf';
75.
76. Database altered.
77.
78. SQL> recover datafile 5;
79. ORA-00279: change 454443 generated at 05/07/2010 16:32:07 needed for thread 1
80. ORA-00289: suggestion :
81. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_8_
%u_.arc
82. ORA-00280: change 454443 for thread 1 is in sequence #8
83.
84.
85. Specify log: {=suggested | filename | AUTO | CANCEL}
86. auto
87. ORA-00279: change 454869 generated at 05/07/2010 16:41:38 needed for thread 1
88. ORA-00289: suggestion :
89. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_9_
%u_.arc
90. ORA-00280: change 454869 for thread 1 is in sequence #9
91. ORA-00278: log file
92. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_8_5y7xcbrm_.arc' no longer needed for this recovery
93. .....
94. .......
95. ORA-00279: change 454874 generated at 05/07/2010 16:41:45 needed for thread 1
96. ORA-00289: suggestion :
97. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_11_
%u_.arc
98. ORA-00280: change 454874 for thread 1 is in sequence #11
99. ORA-00278: log file
100. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_10_5y7xck8j_.arc' no longer needed for this recovery
101.
102.
103. Log applied.
104. Media recovery complete.
105. SQL> alter database datafile 5 online;
106.
107. Database altered.
108.
109. SQL> conn jay/jay;
110. Connected.
111. SQL> select * from demo;
112.
113. ID
114. ----------
115. 321
116.
117. SQL>
5.Restore and Recovery of a Datafile to a different location.
If a non system datafile is missing and its original location not available, restore
can be made to a different location and recovery performed.
Pre requisites: All relevant archived logs.
1. Use OS commands to restore the missing or corrupted datafile to the new
location, ie:
cp -p /user/backup/uman/user01.dbf /user/oradata/u02/dbtst/user01.dbf
2. alter tablespace offline immediate;
3. alter tablespace rename datafile
'/user/oradata/u01/dbtst/user01.dbf' to '/user/oradata/u02/dbtst/user01.dbf';
4. recover tablespace ;
5. alter tablespace online;
workshop 5:
view plaincopy to clipboardprint?
1. SQL> create user lachu identified by lachu
2. 2 default tablespace users;
3.
4. User created.
5.
6. SQL> grant dba to lachu;
7.
8. Grant succeeded.
9.
10. SQL> conn lachu/lachu;
11. Connected.
12. SQL> create table test_tb(id number);
13.
14. Table created.
15.
16. SQL> insert into test_tb values(123);
17.
18. 1 row created.
19.
20. SQL> commit;
21.
22. Commit complete.
23.
24. SQL> conn sys/oracle as sysdba;
25. Connected.
26. SQL> ---manually deleting users01.dbf datafile for testing purpose
27. SQL> host rm -rf '/u01/app/oracle/oradata/testdb/users01.dbf'
28.
29. SQL> conn lachu/lachu;
30. Connected.
31. SQL> select * from tab;
32.
33. TNAME TABTYPE CLUSTERID
34. ------------------------------ ------- ----------
35. TEST_TB TABLE
36. SQL> select * from test_tb;
37. select * from test_tb
38. *
39. ERROR at line 1:
40. ORA-00376: file 4 cannot be read at this time
41. ORA-01110: data file 4: '/u01/app/oracle/oradata/testdb/users01.dbf'
42.
43.
44. SQL> conn sys/oracle as sysdba;
45. Connected.
46. SQL> alter database datafile 4 offline;
47.
48. Database altered.
49.
50. SQL> host cp -p /u01/app/oracle/oradata/backup/users01.dbf /u03/oradata/
users01.dbf
51. --restore datafile user01.dbf to new disk from the recent backup of the database
.
52.
53. SQL> alter tablespace users rename datafile
54. 2 '/u01/app/oracle/oradata/testdb/users01.dbf' to '/u03/oradata/users01.dbf';
55. Tablespace altered.
56.
57. SQL> recover datafile 4;
58. ORA-00279: change 454383 generated at 05/07/2010 01:40:11 needed for thread 1
59. ORA-00289: suggestion :
60. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_7_
%u_.arc
61. ORA-00280: change 454383 for thread 1 is in sequence #7
62.
63.
64. Specify log: {=suggested | filename | AUTO | CANCEL}
65. auto
66. ORA-00279: change 456007 generated at 05/07/2010 12:46:10 needed for thread 1
67. ORA-00289: suggestion :
68. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_8_
%u_.arc
69. ORA-00280: change 456007 for thread 1 is in sequence #8
70. ORA-00278: log file
71. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_7_5y7hkty0_.arc' no longer needed for this recovery
72. ....
73. ......
74. ORA-00279: change 457480 generated at 05/07/2010 13:09:30 needed for thread 1
75. ORA-00289: suggestion :
76. /u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/o1_mf_1_15_
%u_.arc
77. ORA-00280: change 457480 for thread 1 is in sequence #15
78. ORA-00278: log file
79. '/u01/app/oracle/flash_recovery_area/TESTDB/archivelog/2010_05_07/
o1_mf_1_14_5y7jxlvg_.arc' no longer needed for this recovery
80.
81.
82. Log applied.
83. Media recovery complete.
84. SQL> alter database datafile 4 online;
85.
86. Database altered.
87.
88. SQL> select name from v$datafile;
89.
90. NAME
91. ---------------------------------------------
92. /u01/app/oracle/oradata/testdb/system01.dbf
93. /u01/app/oracle/oradata/testdb/undotbs01.dbf
94. /u01/app/oracle/oradata/testdb/sysaux01.dbf
95. /u03/oradata/users01.dbf ----------restored in new location (disk)
96.
97. SQL> conn lachu/lachu;
98. Connected.
99. SQL> select * from tab;
100.
101. TNAME TABTYPE CLUSTERID
102. ------------------------------ ------- ----------
103. TEST_TB TABLE
104.
105. SQL> select * from test_tb;
106.
107. ID
108. ----------
109. 123
regards,
rajeshkumar govindarajan
POSTED BY RAJESHKUMAR GOVINDARAJAN AT FRIDAY, MAY 07, 2010 0 COMMENTS
LINKS TO THIS POST
LABELS: 9I CONCEPTS, RMAN
THURSDAY, DECEMBER 31, 2009
Recover Catalog RMAN
This chapter show how to create the Rman catalog, how to register a database
with it and how to review some of the information contained in the catalog.
The catalog database is usually a small database it contains and maintains the
metadata of all rman backups performed using the catalog.
1.Creating and Register a database with Recovery
Catalog
step1: create a tablespace for storing recovery catalog information in recovery
catalog database
here my recovery catalog database is demo1
[oracle@rac2 bin]$ . oraenv
ORACLE_SID = [oracle] ? demo1
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
[oracle@rac2 bin]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.1.0.6.0 - Production on Thu Dec 31 10:28:22 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> startup
ORACLE instance started.
Total System Global Area 481267712 bytes
Fixed Size 1300716 bytes
Variable Size 226494228 bytes
Database Buffers 247463936 bytes
Redo Buffers 6008832 bytes
Database mounted.
Database opened.
SQL> CREATE TABLESPACE RMAN DATAFILE
'/u01/app/oracle/oradata/demo1/rman01.dbf' size 1000m;
step 2: create a user for recovery catalog and assign a tablespace and resources
to that user
SQL> create user sai identified by sai default tablespace rman quota unlimited
on rman;
SQL> grant connect,resource, recovery_catalog_owner to sai;
step 3: Connect to recovery catalog and register the database with recovery
catalog:
[oracle@rac2 bin]$ . oraenv
ORACLE_SID = [oracle] ? demo1
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
[oracle@rac2 bin]$ rman target /
RMAN> connect catalog sai/sai@demo1;
RMAN> create catalog;
RMAN> register database;
RMAN> report schema;
2.How to register a new database with RMAN recovery
catalog
Replace username/password with the actual username and password for
recovery catalog; and
DEMO1 with the name of the recovery catalog database and new database
name ANTO
1. Change SID to the database you want to register
. oraenv
ORACLE_SID
2. Connect to RMAN catalog database
rman target / catalog username/password@DEMO1
3. Register database
RMAN> register database;
example:
[oracle@rac2 bin]$ . oraenv
ORACLE_SID = [anto] ? anto
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is /u01/app/oracle
[oracle@rac2 bin]$ rman target / catalog sai/sai@demo1;
Recovery Manager: Release 11.1.0.6.0 - Production on Thu Dec 31 10:32:15 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ANTO (DBID=2484479252)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
verification:
connect to the recovery catalog database demo1 and connect as recovery
catalog user sai;
SQL> conn sai/sai;
Connected.
SQL> select * from db;
DB_KEY DB_ID CURR_DBINC_KEY
---------- ---------- --------------
1 3710360247 2
141 2484479252 142
3. Unregister the database from recovery catalog:
Login as rman catalog owner in sql*plus prompt
SQL> select * from rc_database where dbid = DBID;
SQL> exec dbms_rcvcat.unregisterdatabase(DBKEY, DBID);
example:
SQL> select * from rc_database where dbid = DBID;
DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
1 2 3710360247 DEMO1 594567 29-DEC-09
141 142 2484479252 ANTO 522753 30-DEC-09
SQL>exec dbms_rcvcat.unregisterdatabase(141, 2484479252);
SQL> select * from rc_database where dbid = DBID;
DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
1 2 3710360247 DEMO1 594567 29-DEC-09
SUCCESSFULLY, REMOVED THE DATABASE ANTO FROM THE RECOVER CATALOG
regards,
rajeshkumar g, database administrator
for more information about recovery catalog and rman commands:
http://www.tiplib.com/kb/25/1/rman
POSTED BY RAJESHKUMAR GOVINDARAJAN AT THURSDAY, DECEMBER 31, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 10G CONCEPTS, 11G CONCEPTS, 9I CONCEPTS, RMAN
THURSDAY, DECEMBER 24, 2009
changing database dbid
SQL> startup mount
ORACLE instance started.
Total System Global Area 481267712 bytes
Fixed Size 1300716 bytes
Variable Size 226494228 bytes
Database Buffers 247463936 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[oracle@rac1 ~]$ . oraenv
ORACLE_SID = [demo2] ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 is
/u01/app/oracle
[oracle@rac1 ~]$ nid target = /
DBNEWID: Release 11.1.0.6.0 - Production on Thu Dec 24 20:05:44 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to database DEMO2 (DBID=3682169720)
Connected to server version 11.1.0
Control Files in database:
/u01/app/oracle/oradata/demo2/control01.ctl
/u01/app/oracle/oradata/demo2/control02.ctl
/u01/app/oracle/oradata/demo2/control03.ctl
Change database ID of database DEMO2? (Y/[N]) => y
Proceeding with operation
Changing database ID from 3682169720 to 3682222232
Control File /u01/app/oracle/oradata/demo2/control01.ctl - modified
Control File /u01/app/oracle/oradata/demo2/control02.ctl - modified
Control File /u01/app/oracle/oradata/demo2/control03.ctl - modified
Datafile /u01/app/oracle/oradata/demo2/system01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/demo2/sysaux01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/demo2/undotbs01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/demo2/users01.dbf - dbid changed
Datafile /u01/app/oracle/oradata/demo2/temp01.dbf - dbid changed
Control File /u01/app/oracle/oradata/demo2/control01.ctl - dbid changed
Control File /u01/app/oracle/oradata/demo2/control02.ctl - dbid changed
Control File /u01/app/oracle/oradata/demo2/control03.ctl - dbid changed
Instance shut down
Database ID for database DEMO2 changed to 3682222232.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
[oracle@rac1 ~]$
SQL> alter database open resetlogs;
Database altered.
SQL> select dbid from v$database;
DBID
----------
3682222232
regards,
rajeshkumar g
POSTED BY RAJESHKUMAR GOVINDARAJAN AT THURSDAY, DECEMBER 24, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 10G CONCEPTS, 11G CONCEPTS, 9I CONCEPTS, CLONING
THURSDAY, DECEMBER 3, 2009
Setting Up AUTOTRACE in SQL*Plus
AUTOTRACE is a facility within SQL*Plus that shows you the explain plan of the
queries you’ve executed and the resources they used. This topic makes
extensive use of the AUTOTRACE facility.
There is more than one way to get AUTOTRACE configured. This is what I like to
do to get AUTOTRACE working:
1. cd [ORACLE_HOME]/rdbms/admin
2. log into SQL*Plus as SYSTEM
3. Run @utlxplan
4. Run CREATE PUBLIC SYNONYM PLAN_TABLE FOR PLAN_TABLE;
5. Run GRANT ALL ON PLAN_TABLE TO PUBLIC;
You can replace the GRANT TO PUBLIC with some user if you want. By making
the PLAN_TABLE public, you let anyone trace using SQL*Plus (not a bad thing, in
my opinion). This prevents each and every user from having to install his or her
own plan table. The alternative is for you to run @utlxplan in every schema from
which you want to use AUTOTRACE.
The next step is creating and granting the PLUSTRACE role:
1. cd [ORACLE_HOME]/sqlplus/admin
2. Log in to SQL*Plus as SYS or as SYSDBA
3. Run @plustrce
4. Run GRANT PLUSTRACE TO PUBLIC;
Again, you can replace PUBLIC in the GRANT command with some user if you
want.
About AUTOTRACE
You can automatically get a report on the execution path used by the SQL
optimizer and the statement execution statistics. The report is generated after
successful SQL DML (i.e., SELECT, DELETE, UPDATE, MERGE, and INSERT)
statements. It is useful for monitoring and tuning the performance of these
statements.
Controlling the Report
You can control the report by setting the AUTOTRACE system variable:
• SET AUTOTRACE OFF: No AUTOTRACE report is generated. This is the
default.
• SET AUTOTRACE ON EXPLAIN: The AUTOTRACE report shows only the
optimizer execution path.
• SET AUTOTRACE ON STATISTICS: The AUTOTRACE report shows only the
SQL statement execution statistics.
• SET AUTOTRACE ON: The AUTOTRACE report includes both the optimizer
execution path and the SQL statement execution statistics.
• SET AUTOTRACE TRACEONLY: This is like SET AUTOTRACE ON, but it
suppresses the printing of the user’s query output, if any.
regards,
rajeshkumar govindarajan
POSTED BY RAJESHKUMAR GOVINDARAJAN AT THURSDAY, DECEMBER 03, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS
MONDAY, NOVEMBER 16, 2009
Backup &Recovery Scenarios
Backup &Recovery Scenarios
by Muhammad Abdul Halim
To check database mode
> archive log list
To bring database in archive log mode
> startup mount
> alter database archivelog;
To start ARCN process
log_archive_start=true
log_archive-max_process=2(max 10)
> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=3;
> ALTER SYSTEM ARCHIVE LOG START STOP
To define archive format
log_archive_format=TS%S.ARC
Data Dictionary Format
V$ARCHIVED_LOG V$ARCHIVE_DEST
V$LOG_HISTORY V$ARCHIVE_PROCESSES
To define archive destination : Up to 4 destination can be defined
log_archive_dest=’/clover/archive’
log_archive_duplex_dest=’/clover/archive’
OR
log_archive_dest_1=”LOCATION=/clover/arch”
Mandatory Reopen=500(Default 300) Optional
log_archive_min_succeed_dest=2
log_archive_dest_state_3=DEFER / ENABLE
> ALTER SYSTEM SET log_archive_dest_state_3=ENABLE;
log_archive_dest_state_2=”SERVICE=standby”
To defining archive destination in open database
> ALTER SYSTEM ARCHIVE LOG START TO ’/clover/arch’;
Selectively Archiving
> ALTER SYSTEM ARCHIVE LOG SEQUENCE 052;
BACKUP AND RECOVERY
Media Failure and Recovery:
Database in NOARCHIVELOG Mode
Failure : loss of disk,data file,or corruption
Recovery : Restore all Oracle files:
- Data files
- Control files
- Redo log files
- Password file (optional)
- Parameter file (optional)
Advantage
· Easy to perform with low risk of error
· Recovery time is the time it takes to restore all files.
Disadvantage
· Data is lost and must be reapplied manually
· The entire database is restored to the point of the last whole closed backup
Recovery
> shutdown
Restore all files using operating system
> startup
Restoring to a Different Location
> startup mount
> alter database rename file ’/clover/oradata/user_01.dbf’ to
’/clover/oradata/user_01.dbf’;
> alter database open;
Media Failure and Recovery:
ARCHIVELOG Mode
Failure : loss of disk,data file,or corruption
Recovery
- Data files for restore must be offline.
- Restore only lost or damaged data files
- Do not restore the control files, redo log files, password files, or parameter files
- Recover the data files.
Advantages
· Only need to restore lost files
· Recovers all data to the time of failure
· Recovery time is the time it takes to restore lost files and apply all archived log
files
Disadvantages
· Must have all archived log files since the backup from which you are restoring
Complete recovery
· Closed database recovery for
- System data files
- Rollback segment data files
- Whole database
· Opened database recovery, with database initially opened : for file loss
· Opened database recovery with database initially closed : for hardware failure
· Data file recovery with no data file backup
Incomplete recovery
· Time based
· Cancel based
· Using control file
· Change based
Closed database backup
No archive log mode
Data files, Control files, Redolog files, Parameter file, Password file
> SHUTDOWN IMMEDIATE
cp /backup
> STARTUP OPEN;
Open database backup
Archive log mode
Data files, Control files, Parameter file, Password file
Arch process must be enabled
> alter tablespace TEST begin backup;
cp /clover/data/test.dbf /clover/backup/test.dbf
> alter tablespace TEST end backup;
Creating a binary image;
> alter database backup controlfile to ‘controll.bk
Creating a text trace file:
> alter database backup controlfile to trace;
Case Study for Backup and recovery
Backups
I. Closed database backup
Note : To keep backup, create one subfolder in your main folder Every day
before shutdown delete all your backups.
Database may in no archive/archive log mode
Take backup of all files Data files, Control files, Redolog files,
Parameter file, Password file (optional )
> SHUTDOWN IMMEDIATE;
Copy all files to backup location using operating system.
cp /clover/backup/
> STARTUP OPEN;
II Open database backup
Database must be in archive log made
ARCN process must be enabled
Take backup of Data files, Control files
Password file and Parameter file is optional
> alter tablespace test begin backup;
Copy datafile of test tablespace to backup location using operating system.
cp /oracle/db01/data/test.dbf /oracle/backup/test.dbf
> alter tablespace test end backup;
Note : Perform open database backup for all tablespaces
Creating a binary image of control file
> alter database backup controlfile to ‘controll.bkp; path should be specified
Creating a text trace file
> alter database backup controlfile to trace; path should be specified
Recovery
Recovery in No Archive log mode :
Advantage : Easy to perform with minimum risk
Recovery time is time taken for restore the files from backup
Disadvantage : Data lost must be reapplied manually
Database is recovered to time of last backup.
Possible media failure : Loss of disk, datafile or corruption of datafile.
Requirement : Last valid closed database backup.
Recovery : Restore all datafiles, control files, redolog files.
Recover the database.
Note : if log sequence no is not changed after taking the backup no need restore
all file.
Scenario 1
Shutdown the database.
> shutdown
copy all datafiles, control files, redolog files to backup folder using operating
system.
Delete one datafile using operating system.
> startup ( Database will go to mount stage giving an error )
Recovery
Restore damaged datafile from backup using operating system and recover
cp /oracle/backup /oracle/db01/data
> alter database open ;
Scenerio 2
Force the log switch to change the log seq no.
> alter system switch logfile;
> alter system switch logfile;
> alter system switch logfile;
Shutdown the database.
> shutdown
Delete one datafile using operating system.
> startup ( Database will go to mount stage giving an error )
Recovery
Restore all files.
> alter database open ;
Recovery in Archive log mode : ( Complete Recovery )
Advantage : Restore damaged datafile
Recover all data to the time od failure
Recovery time is time taken to restore datafile and apllying the archive logs.
Disadvantage : Require all archive logs since the backup from which are
restored
Possible media failure : Loss of disk , datafile or corruption of datafile.
Requirement : Last valid backup after seting database in archive log mode.
All archive logs and online redologs which are not yet archived
Recovery : Startup the database in mount/open stage
Restore damaged datafile from backup using operating system recover
Recover the datafile.
Recovery syntax
Recovering in mount stage
> Recover database
> Recover datafile ’’;
> Alter database recover database;
Manual recovery
If archive log destination is not defined in the parameter file
Oracle server has to be informed about the location of the file archive logs.
> Alter system archive log start to ;
To recover also you have to define the archive log location
> recover from <> database;
Automatic recovery
Before recover set auto recovery on.
> set auto recovery on;
> recover datafile ‘’;
Enter auto when prompted for a redolog file.
> Auto
Or
> recover automatic datafile ‘’
Check V$recover_file - which file need recovery
V$recovery_log - archive log need for recovery
Recovery in Archive log mode : ( Complete Recovery )
Scenario 3 ( In mount stage )
Force the log switch to change the log seq no.
> alter system switch logfile ;
> alter system switch logfile;
> alter system switch logfile ;
shutdown the database.
> shutdown immediate ;
Delete system datafile using operating system.
> startup ( Database will go to mount stage giving an error )
ORA-01157 : cannot identify/lock data file 1 – see DBWR trace file
ORA-01110 : data file 1 : ‘/clover/system01.dbf'
Restore system datafile from backup using oprating system and recover the
datafile
> Recover datafile ‘/clover/data/sys.dbf’ ;
> Alter database open ;
Scenario 4 ( Initially closed, open stage )
Shutdown the database.
> shutdown immediate ;
Delete non system datafile using operating systm.
> startup ( Database will go to mount stage giving an error )
ORA-01157 : cannot Identify/lock data file 3 – see DBWR trade file
ORA-01110 : data file 3 : ‘/clover/test.dbf’
Check V$ datafile header
Take the lost datafile offline
> Alter database datafile ‘/clover/test.dbf’ offline;
Restore the lost datafile from backup and recover the datafile.
> Recover datafile /clover/test.dbf ;
Bring the datafile online.
> Alter database datafile ‘/clover/test.dbf’ online;
Note : if you want to restore the damaged datafile to different location oracle
must
Be informed about new location by renaming recovery
> Alter database rename file ‘/clover/test.dbf’ to ‘/new/test.dbf’ ;
Backup Recovery
Recovery in Archive log mode : ( Complete Recovery )
Scenario 5 ( without backup )
Shutdown the database.
> shutdown immediate ;
Delete non system datafile using operating system.
> startup ( Database will go to mount stage giving an error )
ORA-01157 : cannot identify/lock data file 3 – see DBWR trace file
ORA-01110 : data file 3 : ‘/clover/test.dbf’
Take the lost datafile oflinne
> Alter database datafile ‘/clover/test.dbf’ ofline;
open the database
> Alter database open ;
Take database offile immediate to avoid check point trying to write to datafile.
> Alter tablespace test offline immediate ;
Since you do not have backup operate create the datafile
> Alter database create datafile ‘/clover/test.dbf’ as ‘/clover/test.dbf’;
Recover the Database
> Recover datafile ‘/clover/test.dbf’;
> Alter tablespace test online ;
Scenerio 6 Recovery of file in backup mode
Startup online backup
> Alter tablespace test begin backup ;
switch off the system and restart .
startup the database if it is already starting shut it down then startup. It will ask
for media recovery
ORA-01113 : file 3 needs media recovery
ORA-01110 : data file 3 : ‘/clover/test.dbf’
Check V$Backup
> Recover datafile '/clover/test.dbf’;
OR
> Alter database datafile 3 end backup ;
check V$Backup
Since the datafile header was frozen the database files were not synchronized.
Loss of inactive Redolog files
If redo logs are lost recovery to the time of failure is not possible but if lost
redologs are not current, the redolog has been archived and proper
mulltiplexing of redo logs are available no data will be lost.
Scenario 7
Check V$Logfile for current logfile and delete one fo the redlog file which is not
current.
Using operating system. Force the log switch
> Alter system switch logfile;
it will give an eror
ORA- 00313 : open failed for members of log group of thread 1
Incomplete Recovery
In incomplete recovery database will be recovered before the time of failure.
Possible Failures : A failed complete recovery operation, Important table in the
Database is dropped, A control file is lost, Loss of redolog files
Rquirement : Valid online or offline backup of all the database files.
Need all archived logs ,Back up of control file.
Recovery : Shutdown and backup the database.
Restore all data files.
Do not restore the control file, redo logs, password files, or
Parameter files.
Mount the database and recover the data file before time of failure.
Perform a closed database backup.
Recovery Guidelines :
· Follow all steps: Most errors occur during this type of recovery.
· Whole-database backup before and after recovery assist future recovery.
· Always verify that the recovery is successful.
· Back up the control file regularly.
· Back up and remove archived logs.
· Database are brought forward in time, not bake in time.
Time based recovery
Scenerio 8 : A table is dropped at 10 am at 11 am user comes to know that the
table view or table does not exist
Create a table test.
> Create table test ( n number );
Insert values
> Insert into test values (11111);
> Commit ; > Alter system switch logfile ; Note down the commit timing. Give
some time gap and drop the table
> Drop table test ;
Shutdown the database
> Shutdown
Mount the databse
> Startup mount ; Restore all datafile from backup (most recent ) using
operating system. And recover the database until time (Specify time before
droping the table )
> Recover database until time ‘2001-11-12:09:30:00’; > Alter database open
resetlogs ; After incomplete recovery take new backup of database.
Select * from nls_database_parameter;
Cancel based recovery
Scenario 9 : Lost a redolog file
Shutdown the database.
Take back up of all logfiles, datafiles, controlfiles
Delete one log file using operating system.
Mount the database
> startup mount ;
Restore all datafile from backup using system.
> recover database until cancel ;
> Alter database open resetlogs ;
Check for log file in v$ logfile
Change based recovery
Scenerio 10 : No back up was taken after reset logs, need is to use cold backup
Backup the data file and control file. ( cold backup )
Perform incomplete recovery ( To bring database in new incarnation you can
recover by time based or cancel based )
Create a table insert some records commit. Shutdown the database.
> Shutdown
Restore cold data file and control file ( from cold backup)
Startup the database. ( You will get an error )
> Startup
Check V$Log for change seq #)
Recover until Change
> recover database until change <>;
> Alter database open resetlog :
Check for table created.
Scenerio 11
Recovery using backup controlfile
Tablespace was created at 10am and backup was taken and dropped at 2pm
Create a tablespace and create one table insert records into the table.
Take backup of all datafile and controlfile ( closed/open if you are taking open
database backup first take backup of controlfile than datafile )
Drop the tablespace.
> Drop tablespace test including contents ;
Shutdown the database take backup of existing controlfile first than restore
controlfile and datafile.
Startup the database it will give an error after taking the database in mount
stage.
Make sure that all datafiles are online before recovery by checking
v$recover_file Perform recovery using backup controlfile
> recover database until time ‘2001-11-11:13:10:00’ using backup controlfile;
> Alter database open resetlogs ; Check for the table.
Scenario 12
Backup was taken of both controlfile and datafile at 10 am. At 11 am Tablespace
was created and at 1pm tablespace was dropped. Recover the tablespace using
cold backup.
Scenario 13
A table test was created at 10am and dropped at 10.30 am, another table test1
was dropped at 10.45am. Recover the tables without losing any records in both
the table.
Scenario 14
Recover the lost current control file, or the current control file is inconsistent
with files that you need to recover
Scenario 15
Recover lost online redo logs.
Scenario 16
Recover new information that was not in the backup and was only stored in the
archivelog files.
Scenario 17
How to recover a database having added a datafile since the last backup.
Scenario 18
If the database crashes during a hot backup.
source and reference:
http://halimdba.blogspot.com/2009/02/backup-seneries.html
POSTED BY RAJESHKUMAR GOVINDARAJAN AT MONDAY, NOVEMBER 16, 2009 1
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS
Monitoring the Primary and Standby Databases
Table indicates whether a primary database event is automatically administered
by log transport services and log apply services or requires additional
intervention by the database administrator (DBA) to be propagated to the
standby database. It also describes how to respond to these events.
Troubleshooting Primary Database Events
regards,
rajeshkumar govindarajan.
source and reference:
http://www-css.fnal.gov/dsg/external/oracle_dcm/9iv2/server.920/a96653/
sbydb_manage_ps.htm#1005701
related topics
# Dynamic Performance Views (Fixed Views)For Manganing Standby Database
# Determining Which Logs Have Been Applied to the Standby Database
# Determining Which Logs Have Not Been Received by the Standby Site
POSTED BY RAJESHKUMAR GOVINDARAJAN AT MONDAY, NOVEMBER 16, 2009 1
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS, DATAGUARD, MANAGING PHYSICAL STANDBY DATABASE
Determining Which Logs Have Been Applied to the Standby
Database
Query the V$LOG_HISTORY view on the standby database, which records the
latest log sequence number that has been applied. For example, issue the
following query:
SQL> SELECT THREAD#, MAX(SEQUENCE#) AS "LAST_APPLIED_LOG"
2> FROM V$LOG_HISTORY
3> GROUP BY THREAD#;
THREAD# LAST_APPLIED_LOG
------- ----------------
1 967
In this example, the archived redo log with log sequence number 967 is the
most recently applied log.
You can also use the APPLIED column in the V$ARCHIVED_LOG fixed view on the
standby database to find out which log is applied on the standby database. The
column displays YES for the log that has been applied. For example:
SQL> SELECT THREAD#, SEQUENCE#, APPLIED FROM V$ARCHIVED_LOG;
THREAD# SEQUENCE# APP
---------- ---------- ---
1 2 YES
1 3 YES
1 4 YES
1 5 YES
1 6 YES
1 7 YES
1 8 YES
1 9 YES
1 10 YES
1 11 NO
10 rows selected.
regards,
rajeshkumar govindarajan.
source and reference:
http://www-css.fnal.gov/dsg/external/oracle_dcm/9iv2/server.920/a96653/
sbydb_manage_ps.htm#1005911
related topics:
Determining Which Logs Have Not Been Received by the Standby Site
Dynamic Performance Views (Fixed Views) for managing standby
database
POSTED BY RAJESHKUMAR GOVINDARAJAN AT MONDAY, NOVEMBER 16, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS, DATAGUARD, MANAGING PHYSICAL STANDBY DATABASE
Determining Which Logs Have Not Been Received by the
Standby Site
Each archive destination has a destination ID assigned to it. You can query the
DEST_ID column in the V$ARCHIVE_DEST fixed view to find out your destination
ID. You can then use this destination ID in a query on the primary database to
discover logs that have not been sent to a particular standby site.
For example, assume the current local archive destination ID on your primary
database is 1, and the destination ID of one of your remote standby databases is
2. To find out which logs have not been received by this standby destination,
issue the following query on the primary database:
SQL> SELECT LOCAL.THREAD#, LOCAL.SEQUENCE# FROM
2> (SELECT THREAD#, SEQUENCE# FROM V$ARCHIVED_LOG WHERE
DEST_ID=1) LOCAL
3> WHERE
4> LOCAL.SEQUENCE# NOT IN
5> (SELECT SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=2 AND
6> THREAD# = LOCAL.THREAD#);
THREAD# SEQUENCE#
---------- ----------
1 12
1 13
1 14
The preceding example shows the logs that have not yet been received by
standby destination 2.
regards,
rajeshkumar govindarajan
source and reference:
http://www-css.fnal.gov/dsg/external/oracle_dcm/9iv2/server.920/a96653/
sbydb_manage_ps.htm#1005941
related topics:
Dyanamic performance views for managing standby database
Determine which Log Have Been Applied to the standby database
POSTED BY RAJESHKUMAR GOVINDARAJAN AT MONDAY, NOVEMBER 16, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS, DATAGUARD, MANAGING PHYSICAL STANDBY DATABASE
Monitoring Events That Affect the Standby Database
To prevent possible problems, you should be aware of events that affect a
standby database and learn how to monitor them. Most changes to a primary
database are automatically propagated to a standby database through archived
redo logs and thus require no user intervention. Nevertheless, some changes to
a primary database require manual intervention at the standby site.
Dynamic Performance Views (Fixed Views)
The Oracle database server contains a set of underlying views that are
maintained by the server. These views are often called dynamic performance
views because they are continuously updated while a database is open and in
use, and their contents relate primarily to performance. These views are also
called fixed views, because they cannot be altered or removed by the database
administrator.
These view names are prefixed with either V$ or GV$, for example,
V$ARCHIVE_DEST or GV$ARCHIVE_DEST.
Standard dynamic performance views (V$ fixed views) store information on the
local instance. In contrast, global dynamic performance views (GV$ fixed views),
store information on all open instances. Each V$ fixed view has a corresponding
GV$ fixed view.
The following fixed views contain useful information for monitoring the Data
Guard environment:
* V$ARCHIVE_DEST
Describes the archived redo log destinations associated with the current
instance on the primary site. You can use this view to find out the current
settings of your archived redo log destinations.
* V$ARCHIVE_DEST_STATUS
This view, an extension of the V$ARCHIVE_DEST view, displays runtime and
configuration information for the archived redo log destinations. You can use
this view to determine the progress of archiving to each destination. It also
shows the current status of the archive destination.
* V$ARCHIVE_GAP
Provides information about archive gaps on a standby database. You can use
this view to find out the current archive gap that is blocking recovery.
* V$ARCHIVED_LOG
Displays archived redo log information from the control file, including archived
log names. This view gives you information on which log has been archived to
where on your primary database. On the primary database, this view describes
the logs archived to both the local and remote destinations. On a standby
database, this view provides information about the logs archived to this standby
database. You can use this fixed view to help you to track archiving progress to
the standby system by viewing the applied field.
* V$DATABASE
Contains database information from the control file. You can use this view to
quickly find out if your database is a primary or a standby database, as well as
its switchover status and standby database protection mode.
* V$DATAFILE
Contains datafile information from the control file. You can query this fixed view
to verify that the standby datafiles are correctly renamed after your standby
database is re-created.
* V$DATAGUARD_STATUS
Displays and logs events related to Data Guard since the instance was started.
* V$LOG
Contains log file information from the online redo logs. You can use the
information about the current online log on the primary database from this view
as a reference point to determine how far behind your standby database is in
receiving and applying logs.
* V$LOGFILE
Contains static information about the online redo logs and standby redo logs.
* V$LOG_HISTORY
Contains log history information from the control file, including a record of the
latest archived log that was applied.
* V$MANAGED_STANDBY
Displays current and status information for some Oracle database server
processes related to Data Guard. This view can show both foreground and
background processes. You can use this view to monitor the various Data Guard
recovery and archiving processes on the standby system.
* V$STANDBY_LOG
Provides information about the standby redo logs. Standby redo logs are similar
to online redo logs, but they are only used on a standby database receiving logs
from the primary database using the log writer process.
regards,
rajeshkumar govindarajan
source and reference:
http://www-css.fnal.gov/dsg/external/oracle_dcm/9iv2/server.920/a96653/
sbydb_manage_ps.htm
related topics:
Determining Which Logs Have Not Been Received by the Standby Site
POSTED BY RAJESHKUMAR GOVINDARAJAN AT MONDAY, NOVEMBER 16, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS, DATAGUARD, MANAGING PHYSICAL STANDBY DATABASE
SUNDAY, NOVEMBER 15, 2009
Static data dictionary views
The following views are part of the data dictionary.
Find all views along with a comment in dict:
select * from dict;
USER_ / ALL_ / DBA_
Most static dictionary views come with three prefixes: USER_*, ALL_* and DBA_*.
For example, there's a user_tables, all_tables and a dba_tables view. For brevity,
I only give the names of the views that start with dba_.
Generally, the user_ views show database objects owned by the user who is
querying the user_ view.
The all_ views show the database objects that are accessible to the user who is
querying the all_view.
The dba_ views show all database objects.
Table related data dictionary views
* dba_tables
* dba_tab_columns
* dba_all_tables
* dba_tab_comments
* dba_col_comments
* dba_external_tables
* dba_external_locations
* dba_tab_histograms
* dba_tab_statistics
* dba_tab_col_statistics
* dba_tab_modifications
* dba_encrypted_columns
* dba_unused_col_tabs
* dba_partial_drop_tabs
Registry related data dictionary views
* dba_registry,
* dba_registry_hierarchy,
* dba_registry_history,
* dba_registry_log
XML DB related views
* dba_xml_schemas
* dba_xml_tables
* dba_xml_views
* dba_xml_views_cols
Audit related views
* dba_audit_exists
* dba_audit_object
* dba_audit_policies
* dba_audit_policy_columns
* dba_audit_session
* dba_audit_statement
* dba_audit_trail
* dba_common_audit_trail
* dba_fga_audit_trail
* dba_opj_audit_opts
* dba_priv_audit_opts
* dba_repaudit_attribute
* dba_repaudit_column
* dba_stmt_audit_option_opts
Other static data dictionary views
dba_advisor_findings
Exposes the Oracle 10g's advisors tips.
See also dbms_sqltune
dba_advisor_recommendations
Exposes the Oracle 10g's advisors tips.
See also dbms_sqltune
dba_advisor_rationale
Exposes the Oracle 10g's advisors tips.
See also dbms_sqltune
dba_advisor_tasks
Exposes the Oracle 10g's advisors tips.
See also dbms_sqltune
dba_arguments
This view can be used to find out what arguments a procedure's or object type's
function/procedure has.
See this page for an example of a select statement, or this pagea.
dba_col_privs
dba_constraints
Derives from con$. Records the constraints.
See also On identifiying parent and child tables.
dba_datapump_jobs
This view monitors data pump jobs.
dba_data_files
If a datafile has autoextend on and unlimited maxsize, the maxsize is reported
with a ridiciculous high number such as 1.7180E+10.
file_id vs relative_fno: file_id is unique in a database while relative_fno is 'only'
unique for datafiles within a tablespace.
dba_db_links
dba_directories
Displays all directories that were created with create directory.
Note: There's no user_directories, only dba_directories and all_directories exist!
defcall
This is a view that belongs to the replication catalog.
defdefaultdest
This is a view that belongs to the replication catalog.
deferror
This is a view that belongs to the replication catalog.
It records entries in the error queue.
defpropagator
This is a view that belongs to the replication catalog.
deftran
This is a view that belongs to the replication catalog.
defcalldest
This is a view that belongs to the replication catalog.
deferrcount
This is a view that belongs to the replication catalog.
deflob
This is a view that belongs to the replication catalog.
defschedule
This is a view that belongs to the replication catalog.
deftrandest
This is a view that belongs to the replication catalog.
Use dbms_defer_sys.delete_tran to get rid of entries in deftrandest.
This view records entries in the deferred transaction queue.
flashback_transaction_query
Used for Flashback transaction queries. (See flashback transaction query
example)
global_name
dba_indexes
dba_jobs
dba_jobs_running
dba_lobs
dba_logstdby_log
Can be used to verirfy that archived redo log are being applied to standby
databases.
dba_logstdby_not_unique
dba_logstdby_parameters
dba_logstdby_progress
dba_logstdby_skip
dba_logstdby_skip_transaction
dba_mviews
dba_objects
Displays information about objects.
all_olap2_aw_cubes
Shows all cubes in all analytic workspaces.
all_olap2_aw_dimensions
dba_plsql_object_settings
Stores the values of the following initialization parameters as of compilation
time:
* plsql_ccflags
* plsql_code_type
* plsql_debug
* plsql_optimize_level
* plsql_warnings
* nls_length_semantics
dba_procedures
The column procedure_name is null for procedures and functions, it is only set
for procedures and functions in pl/sql packages. The procedures' and functions'
names are found in the column object_name, however, using dba_procedures, it
is not possible to find out if it is a procedure or function. This is possible with
dba_objects.
dba_profiles
Allows to see the profiles and their settings.
dba_queues
dba_queue_tables
See drop table.
dba_recyclebin
Displays the object in the recycle bin for the currently logged on user.
recyclebin is a synonym for user_recyclebin.
dba_refresh
dba_registered_mview_groups
This is a view that belongs to the replication catalog.
See also materialized view group.
dba_registry
dba_repcat_refresh_templates
This is a view that belongs to the replication catalog.
dba_repcat_template_objects
This is a view that belongs to the replication catalog.
It keeps track of deployent templates.
dba_repcat_template_parms
This is a view that belongs to the replication catalog.
dba_repcat_template_sites
This is a view that belongs to the replication catalog.
dba_repcat_user_authorizations
This is a view that belongs to the replication catalog.
dba_repcat_user_parm_values
This is a view that belongs to the replication catalog.
dba_repcatlog
This is a view that belongs to the replication catalog.
It can be used to track administrative requests.
dba_repcolumn
This is a view that belongs to the replication catalog.
dba_repcolumn_group
This is a view that belongs to the replication catalog.
dba_repconflict
This is a view that belongs to the replication catalog.
dba_repddl
This is a view that belongs to the replication catalog.
dba_repextensions
This is a view that belongs to the replication catalog.
dba_repgenobjects
This is a view that belongs to the replication catalog.
dba_repgroup
This is a view that belongs to the replication catalog.
dba_repgroup_privileges
This is a view that belongs to the replication catalog.
dba_repgrouped_column
This is a view that belongs to the replication catalog.
dba_repkey_columns
This is a view that belongs to the replication catalog.
dba_repobject
This is a view that belongs to the replication catalog.
dba_repparameter_column
This is a view that belongs to the replication catalog.
dba_reppriority
This is a view that belongs to the replication catalog.
dba_reppriority_group
This is a view that belongs to the replication catalog.
dba_repprop
This is a view that belongs to the replication catalog.
dba_represol_stats_control
This is a view that belongs to the replication catalog.
dba_represolution
This is a view that belongs to the replication catalog.
dba_represolution_method
This is a view that belongs to the replication catalog.
dba_represolution_statistics
This is a view that belongs to the replication catalog.
dba_repsites
This is a view that belongs to the replication catalog.
dba_repsites_new
This is a view that belongs to the replication catalog.
dba_rewrite_equivalences
This view can be used to show the equivalences that were established using
dbms_advanced_rewrite.declare_rewrite_equivalence.
dba_roles
This view lists all roles except the special role public.
select name, ##A(decode/ora/sql/decode.html)(password, null, 'NO',
'EXTERNAL', 'EXTERNAL',
'GLOBAL', 'GLOBAL', 'YES')
from user$
where type# = 0 and name not in ('PUBLIC', '_NEXT_USER')
dba_role_privs
Lists roles that are assigned to a either another role or a user.
Here is a script that uses dba_role_privs to recursively list privileges assigned to
users and roles.
dba_segments
This view shows information about segments.
dba_sequences
dba_sequences is a bit special: Unlike dba_tables, dba_indexes, dba_triggers,
dba_constraints, dba_db_links, dba_jobs, dba_queue_tables and dba_queues,
there is no column owner but sequence_owner.
dba_source
dba_sqltune_binds
This view can be used to get the SQL tuning advisors recommondations.
dba_sqltune_plans
This view can be used to get the SQL tuning advisors recommondations.
dba_sqltune_statistics
This view can be used to get the SQL tuning advisors recommondations.
dba_synonyms
Show all synonyms.
dba_sys_privs
Lists system privileges that are assigned to a either another role or a user.
dba_scheduler_job_run_details
system_privilege_map
Lists all system privileges.
These privileges can be audited.
all_sumdelta
Lists direct path load entries accessible to the current user.
dba_tab_privs
all_tab_privs_made
There is no dba_tab_privs_made, only user_tab_privs_made and
all_tab_privs_made.
All_tab_privs_made view lists all object privileges that the current either has
granted or for for which he owns the underlying object.
User_tab_privs_made displays only grants for which the current user is the
object owner.
These views are not role-recursive. That is to say, if I grant an object privilege to
a role, and then grant that role to a user, this view doesn't show me that the
user has that object's privilege.
A related view is all_tab_privs_recd.
all_tab_privs_recd
There is no dba_tab_privs_recd, only user_tab_privs_recd and all_tab_privs_recd.
A related view is all_tab_privs_made.
dba_triggers
See also Getting the nth source code line of a trigger.
dba_ts_quotas
Can be used to find out how big the quota of a user is on a tablespace and how
much thereof he has already occupied.
dba_users
Has a record for each user in the database.
The related view user_users has only one row: the one that belongs to the user
selecting from user_users. See also Who am I.
dba_tablespaces
Displays the tablespaces of a database.
dba_views
regards,
rajeshkumar govindarajan
source and reference:
http://www.adp-gmbh.ch/ora/misc/static_dictionary_views.html
POSTED BY RAJESHKUMAR GOVINDARAJAN AT SUNDAY, NOVEMBER 15, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS
SYS owned tables [Base tables of the Oracle dictionary]
These tables are the base tables in the data dictionary. Their content is exposed
for easier access through SQL through the static dictionary views.
aud$
See auditing and audit (sql).
aux_stats$
pname can take several values, the most usefull beeing:
* MBRC
* SREADTIM
* MREADTIM
* CPUSPEED - In MHz, obviously not always right
* SLAVETHR - Throughput
* ????THR
* BADSTAT(S)
col$
col_usage$
This table allows to monitor the usage of predicates on columns in select
statements.
It is updated (if _column_tracking_level is set to 1) at intervalls by smon, so it
might be a little out of date.
Also, dbms_stats will make use of that info when deciding if it needs to create a
histogram on a column.
select
o.name,
c.name,
u.equality_preds,
u.equijoin_preds,
u.nonequijoin_preds,
u.range_preds,
u.like_preds,
u.null_preds
from
sys.col_usage$ u
join sys.obj$ o on u.obj# = o.obj#
join sys.col$ c on u.obj# = c.obj# and u.intcol# = c.col#;
con$
This table keeps track of constraints. dba_constraints derive from this table.
dbms_lock_allocated
This table stores a row for each lock allocated with dbms_lock.allocate_unique.
fet$
In dictionary managed tablespaces, free extents are maintained in fet$. See also
uet$
mlog$
See also refreshing a materialized view.
obj$
Lists all objects created in a database.
The following statement lists all objects created for the current loged on user:
select * from sys.obj$ where owner# = userenv('SCHEMAID')
prop$
rgroup$
session_privs
This view lists the selecting user's privileges.
See also this page.
slog$
See also refreshing a materialized view.
snap$
See also refreshing a materialized view.
smon_scn_time
smon_scn_time is a table that is filled by SMON every 5 minutes with a
timestamp and the current SCN. However, it only counts 1440 records (=5
days). This makes it possible to roughly find an SCN for a point in time in the last
5 days.
This table is not documented, so only look at it out of curiosity.
uet$
In dictionary managed tablespaces, extents are maintained in uet$. See also
fet$
user$
Contains two types (column type#) of objects: users (type# = 1) and roles
(type# = 0).
user_history$
This table is important to store the history of passwords for a user if password
related profiles are enabled.
regards,
rajeshkumar
source and reference:
http://www.adp-gmbh.ch/ora/misc/sys_tables.html
POSTED BY RAJESHKUMAR GOVINDARAJAN AT SUNDAY, NOVEMBER 15, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS
Dynamic Performance Views
Oracle's V$ Views
v$archive_dest
Shows all archived redo log destinations. Use this view to find out to which place
archived redo logs are copied: select dest_id,destination from v$archive_dest
These values correspond to the init parameter log_archive_dest_n.
v$archive_dest_status
This view allows to find status and errors for each of the defined
v$archived_log
Displays successfully archived redo logs.
shows received logs on a primary standby database.
v$archive_gap
Lists sequence numbers of the archived los that are known to be missing for
each thread on a (physical?) standby database (highest gap only).
v$archive_processes
This view provides information on the archive processes. It can be used to find
out if an ARCH process is active or not.
v$controlfile
Displays the location and status of each controlfile in the database.
v$controlfile_record_section
See sections in a controlfile.
v$bh
This dynamic view has an entry for each block in the database buffer cache.
The column status can be:
* free
This block is not in use
* xcur
Block held exclusively by this instance
* scur
Block held in cache, shared with other instance
* cr
Block for consistent read
* read
Block being read from disk
* mrec
Block in media recovery mode
* irec
Block in instance (crash) recovery mode
v$buffer_pool
See buffer pools.
This view's column id can be joined with x$kcbwds.indx
See also x$kcbwbpd
v$buffer_pool_statistics
v$database
This view lets you access database information. For example, you can check
(using log_mode) whether or not the database is in archivelog mode:
ADPDB>select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
checkpoint_change# records the SCN of the last checkpoint.
switchover_status: can be used to determine if it is possible to perform a
switchover operation Only available for physical standby databases. Can be:
* NOT ALLOWED,
* SESSIONS ACTIVE,
* SWITCHOVER PENDING,
* SWITCHOVER LATENT,
* TO PRIMARY,
* TO STANDBY or
* RECOVERY NEEDED.
See protection modes in data guard for the columns protection_mode and
protection_level.
database_role determines if a database is a primary or a logical standby
database or a physical standby database.
force_logging tells if a database is in force logging mode or not.
v$datafile
This view contains an entry for each datafile of the database.
This view can be used to find out which datafiles must be backed up in a cold
backup: select name from v$datafile
v$datafile_header
Various information about datafile headers. For example, if you're interested in
when the a file's last checkpoint was:
select name, checkpoint_change#, to_char(checkpoint_time, 'DD.MM.YYYY
HH24:MI:SS') from v$datafile_header
v$dataguard_status
Shows error messages in a data guard environment.
v$db_object_cache
This view displays objects that are cached (pinned) in the library cache. See also
dbms_shared_pool.
v$enqueue_stat
If there are a lot of enqueue waits "in" v$session_event or v$system_event,
v$enqueue_stat allows to break down those enqueues in enqueue classes. For
each such class, the gets, waits, failures and the cumulative sum of waited time
can be found.
For a list of enqueue types, refer to enqueue types in x$ksqst.
The column cum_wait_time stems from x$ksqst.ksqstwtim.
v$eventmetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$event_name
Contains a record for each wait event.
v$filemetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$filestat
v$fixed_table
This view contains the name of all V$, X$ and GV$ tables. In oracle 8.1.7, there
are 187 different v$ tables:
ORA81> select count(*) from v where name like 'V$%';
COUNT(*)
----------
185
If you want to know, which x$ tables there are, do a select name from
v$fixed_table where name like 'X$%';
v$fixed_view_definition
Contains the defintion in its attribute view_definition for the views of
v$fixed_table.
v$flash_recovery_area_usage
See also v$recovery_file_dest
v$instance
instance_role can be used to determine if an instance is an active instance
(=primary instance) or a secondary instance (in a standby environment.
dbms_utility.db_version can be used to retrieve the same version as the field
version in v$instance.
v$instance_recovery
Can, for example, be used to determine the optimal size of redo logs.
v$latch
Oracle collects statistics for the activity of all latches and stores these in this
view. Gets is the number of successful willing to wait requests for a latch.
Similarly, misses is how many times a process didn't successfully request a
latch. Spin_gets: number of times a latch is obtained after spinning at least
once. Sleeps indicates how many times a willing to wait process slept.
Waiters_woken tells how often a sleeping process was 'disturbed'.
v$librarycache
v$lock
This view stores all information relating to locks in the database. The interesting
columns in this view are sid (identifying the session holding or aquiring the
lock), type, and the lmode/request pair.
Important possible values of type are TM (DML or Table Lock), TX (Transaction),
MR (Media Recovery), ST (Disk Space Transaction).
Exactly one of the lmode, request pair is either 0 or 1 while the other indicates
the lock mode. If lmode is not 0 or 1, then the session has aquired the lock,
while it waits to aquire the lock if request is other than 0 or 1. The possible
values for lmode and request are:
* 1: null,
* 2: Row Share (SS),
* 3: Row Exclusive (SX),
* 4: Share (S),
* 5: Share Row Exclusive (SSX) and
* 6: Exclusive(X)
If the lock type is TM, the column id1 is the object's id and the name of the
object can then be queried like so: select name from sys.obj$ where obj# = id1
A lock type of JI indicates that a materialized view is being refreshed.
A more detailed example can be found here
See also x$kgllk.
v$locked_object
Who is locking what:
select
oracle_username
os_user_name,
locked_mode,
object_name,
object_type
from
v$locked_object a,dba_objects b
where
a.object_id = b.object_id
v$log
Contains information on each log group. See also online redo log.
Comman values for the status column are:
* UNUSED:
Oracle8 has never written to this group,
* CURRENT:
This is the active group.
* ACTIVE:
Oracle has written to this log before, it is needed for instance recovery.
The active log is the one with the current log sequence number
* INACTIVE:
Oracle has written to this log before; it is not needed for instance recovery.
v$logfile
This view can be queried to find the filenames, group numbers and states of
redo log files. For example, to find all files of group 2, use select member from
v$logfile where group# = 2
v$logmnr_contents
See dbms_logmnr.
v$log_history
This view contains an entry for each Log Switch that occured. The column
first_time indicates the time of the first entry???
On physical standby databases, this view shows applied logs.
v$logstdby
Can be used to verify that archived redo logs are being applied to standby
databases.
v$managed_standby
Monitors the progress of a standby database in managed recovery mode, more
exactly, it displays information about the activities of log transport service and
log apply service.
see here
select process, pid, status, client_process, group# "Stdby Redo Log Gr", block#
from v$managed_standby;
client_process: the corresponding primary database process. If lgwr log
transmission is chosen, one row should have client_process=LGWR. If ARCH
transmission is chosen, one row should have ARCH.
v$mystat
This view records statistical data about the session that accesses it. Join
statistic# with v$statname.
v$sesstat is also similar to v$sysstat, except that v$sysstat accumulates the
statistics as soon as a session terminates.
See also recording statistics with oracle.
v$nls_parameters
The NLS parameters that are in effect for the session quering this view. The view
NLS_SESSION_PARAMETERS is based on v$nls_parameters. See also
v$nls_valid_values.
v$nls_valid_values
This view can be used to obtain valid values for NLS parameters such as
* supported character sets
* languages
* territories
* sorting orders
v$object_usage
v$object_usage gathers information about used (accessed) indexes when an
index is monitored using alter index ... monitoring usage.
See On verifying if an index is used.
v$open_cursor
v$option
This view lets you see which options are installed in the server.
See also dba_registry.
v$parameter
Lists the name-value pairs of the init.ora file (or their default, if not in the
init.ora). For example, if you need to know what your block size is:
select value from v$parameter where name = 'db_block_size'
The columns isses_modifiable and issys_modifiable can be used to determine if
a parameter can be changed at session level using alter session or at system
level using alter system. A parameter is modifiable at session level if
isses_modifiable = 'TRUE'. A parameter is modifiable at system level if
issys_modifiable = 'DEFERRED' or issys_modifiable = 'IMMEDIATE'. However, if a
parameter is changed at system level if issys_modifiable = 'DEFERRED' it only
affects sessions that are started after chaning the parameter. Additionally, the
alter system set ... deferred option must be used.
There are also some undocumented (or hidden?) parameters.
v$pgastat
See also pga.
Thanks to Oleg who notified me of a typo (v$pgastat instead of v$pga_stat).
v$process
Join v$process's addr with v$session paddr.
The column traceid is equal to the value used in alter session set .
v$pwfile_users
Lists all users who have been granted sysdba or sysoper privileges. See adding
user to a password file.
v$recover_file
Useful to find out which datafiles need recovery.
Join with v$datafile to see filenames instead of numbers....
v$recovery_file_dest
See also v$flash_recovery_area_usage
v$reserved_words
This view can be consulted if one is in doubt wheter a particular word is a
reserved word (for example when writing PL/SQL Code or assigning a password
to a user).
Until 10g, the view only consist of two columns: keyword and length. From
10gR2 onwards, it has also the columns reserved, res_type, res_attr, res_semi
and duplicate. Each of these new columns can only be either 'Y' (meaning: yes)
or 'N' (meaning: no)
See also reserved words in SQL and reserved words in PL/SQL.
v$resource_limit
v$rollname
The names of online rollback segments. This view's usn field can be joined with
v$rollstat's usn field and with v$transaction's xidusn field.
v$transaction can be used to track undo by session.
v$rollstat
Statistics for rollback segements
v$session
The column audsid can be joined with sys_context('userenv','SESSIONID') to find
out which session is the "own one". Alternatively, dbms_support.mysid can be
used.
The fields module and action of v$session can be set with
dbms_application_info.set_module. (See v$session_longops for an example.
The field client_info can be set with dbms_application_info.set_client_info
Join sid with v$sesstat if you want to get some statistical information for a
particular sesssion.
A record in v$session contains sid and serial#. These numbers can be used kill a
session (alter system kill session).
A client can set some information in client_info. For example, RMAN related
sessions can be found with
.... where client_info like 'rman%';
What a session is waiting for can be queried with v$session_wait. However, with
Oracle 10g, this is not nessessary anymore, as v$session_wait's information will
be exposed within v$session as well.
See also sessions.
v$sessmetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$session_event
This views is similar to v$system_event. However, it breaks it down to currently
connected sessions.
v$session_event has also the column max_wait that shows the maximum time
waited for a wait event.
v$session_longops
Use v$session_longops if you have a long running pl/sql procedure and want to
give feedback on how far the procedure proceeded.
If the following Procedure is run, it will report its progress in v$session_longops.
The Procedure will also set the module attribute in v$session which makes it
possible to find the sid and serial# of the session.
create table f(g number);
create or replace procedure long_proc as
rindex pls_integer := dbms_application_info.set_session_longops_nohint;
slno pls_integer;
-- Name of task
op_name varchar2(64) := 'long_proc';
target pls_integer := 0; -- ie. The object being worked on
context pls_integer; -- Any info
sofar number; -- how far proceeded
totalwork number := 1000000; -- finished when sofar=totalwork
-- desc of target
target_desc varchar2(32) := 'A long running procedure';
units varchar2(32) := 'inserts'; -- unit of sofar and totalwork
begin
dbms_application_info.set_module('long_proc',null);
dbms_application_info.set_session_longops (
rindex,
slno);
for sofar in 0..totalwork loop
insert into f values (sofar);
if mod(sofar,1000) = 0 then
dbms_application_info.set_session_longops (
rindex,
slno,
op_name,
target,
context,
sofar,
totalwork,
target_desc,
units);
end if;
end loop;
end long_proc;
If the procedure long_proc is run, you can issue the following query to get
feedback on its progress:
select time_remaining,sofar,elapsed_seconds
from v$session_longops l, v$session s
where l.sid=s.sid and l.serial# = s.serial# and s.module='long_proc'
v$session_wait
This views shows what wait event each session is waiting for, or what the last
event was that it waited for.
In contrast, v$session_event lists the cumulative history of events waited for in a
session.
The columns P1, P2 and P3 are parameters that are dependant on the event.
With Oracle 10g, v$session_wait's information will be exposed within v$session
as well.
Since 10g, Oracle displays the v$session_wait information also in the v$session
view.
v$session_wait_history
This view is new in Oracle 10g and allows improved timing and statistics.
v$sesstat
This view is similar to v$mystat except that it shows cumulated statistics for all
sessions.
Join sid with v$session and join statistic# with v$statname.
v$sesstat is also similar to v$sysstat, except that v$sysstat accumulates the
statistics as soon as a session terminates.
v$sga
Shows how much memory the shared global area uses. Selecting * from v$sga is
roughly the same as typing show sga in sql plus with the exeption that the latter
also show the total.
v$sgastat
Showing free space in the sga:
select * from v$sgastat where name = 'free memory'
v$sga_dynamic_components
Information about SGA resize operations since startup.
This view can also be used to find out the granule size of SGA components.
v$sga_resize_ops
v$sort_usage
See temporary tablespaces
v$sort_segment
See Temporary Tablespaces
v$spparameter
Returns the values for the spfile.
v$sql
v$sql is similar to v$sqlarea, the main difference being that v$sql drills down to
select * from x$kglob whereas v$sqlarea drills down to select sum from x$kglob.
See also here.
v$sqlarea
Join v$sqlarea's address with v$session's sql_address.
Find the SQL-text of currently running SQL statements:
select sql_text from v$sqlarea where users_executing > 0;
The field version_count indicates how many versions an sql statement has.
v$sqltext
v$sql_plan
variable addr varchar2(20)
variable hash number
variable child number
exec :addr := '&sqladdr'; :hash := &hashvalue; :child := &childno;
select lpad(' ', 2*(level-1))||operation||' '||
decode(id, 0, 'Cost = '||position) "OPERATION",
options, object_name
from v$sql_plan
start with (address = :addr
and hash_value = :hash
and child_number = :child
and id=0 )
connect by prior id = parent_id
and prior address = address
and prior hash_value = hash_value
and prior child_number = child_number
order by id, position ;
In order to find valid values for sqladdr, hashvalue and childno, this SQL
statement can be used:
select sql_text,address,hash_value,child_number from v$sql where
users_executing > 0;
v$sql_text_with_newlines
This view can be used to construct the entire text for each session's actual SQL
statement. Use the following statement to to that:
set serveroutput on size 1000000
declare
v_stmt varchar2(16000);
v_sql_text v$sqltext_with_newlines.sql_text%type;
v_sid v$session.sid%type;
begin
for r in (
select
sql_text,s.sid
from
v$sqltext_with_newlines t,
v$session s
where
s.sql_address=t.address
order by s.sid, piece) loop
v_sid := nvl(v_sid,r.sid);
if v_sid <> r.sid then
dbms_output.put_line(v_sid);
put_line(v_stmt,100);
v_sid := r.sid;
v_stmt := r.sql_text;
else
v_stmt := v_stmt || r.sql_text;
end if;
end loop;
dbms_output.put_line(v_sid);
dbms_output.put_line(v_stmt,100);
end;
/
Thanks to Sarmad Zafar who notified me of an error in this PL/SQL Block.
Note: the function put_line is found here and can be used to prevent ORU-
10028.
v$sql_bind_data
Join cursor_num with cno of v$sql_cursor.
v$sql_bind_capture
New with Oracle 10g
This view captures bind variables for all sessions and is faster than setting
10046 on level 4.
v$sql_cursor
Join parent_handle with address of v$sql or v$sqlarea.
v$sql_workarea
v$sql_workarea can be joined with v$sqlarea on address and hash_value, and it
can be joined with v$sql on address, hash_value and child_number.
v$standby_log
v$statname
Use this view to get decoded names for the statistic# field of v$mystat,
v$sysstat and v$sesstat.
v$sysaux_occupants
v$sysaux_occupants doesn't exist in Oracle versions prior to Oracle 10g.
See occupants in the sysaux tablepsaces.
v$sysmetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$sysmetric_history
This view is new in Oracle 10g and allows improved timing and statistics.
v$sysstat
v$sysstat is similar to v$sesstat. While v$sesstat displays statitics for the
current session, v$sysstat displays the cumulated statitics since startup of the
database.
For example, it is possible to find out the CPU time (name = 'CPU used by this
session')
This view is (among others) used to calculate the Hit Ratio.
v$system_event
This view displays the count (total_waits) of all wait events since startup of the
instance.
If timed_statistics is set to true, the sum of the wait times for all events are also
displayed in the column time_waited.
The unit of time_waited is one hundreth of a second. Since 10g, an additional
column (time_waited_micro) measures wait times in millionth of a second.
total_waits where event='buffer busy waits' is equal the sum of count in
v$waitstat.
v$enqueue_stat can be used to break down waits on the enqueue wait event.
While this view totals all events in an instance, v$session_event breaks it down
to all currently connected sessions.
v$undostat
undo tablespaces
v$tempfile
v$tempseg_usage
v$tempseg_usage is a public synonym for v$sort_usage.
v$tempstat
v$thread
The Oracle SID can be retrieved through select instance from v$thread
v$timer
This view has only one column (hsecs) which counts hundreths of seconds.
Whenever it overflows four bytes, it starts again with 0.
v$transaction
Important fields of v$transaction are used_ublk and used_urec. They tell of how
many blocks and records the undo for a transaction consists. In order to find out
the name of the corresponding rollback segemnt, join the xidusn field with the
usn field of v$rollname. This is demonstrated in
Transactions generate undo
v$timezone_names
See also timezones for some values of tzabbrev.
v$transportable_platform
Which platforms are supported for cross platform transportable tablespaces.
v$version
Use this view to find out what version you actually work on: select * from
v$version;
BANNER
----------------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE 8.1.7.0.0 Production
TNS for 32-bit Windows: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
v$waitstat
total_waits where event='buffer busy waits' is equal the sum of count in
v$system_event.
regards,
rajeshkumar
from the source
http://www.adp-gmbh.ch/ora/misc/dynamic_performance_views.html
POSTED BY RAJESHKUMAR GOVINDARAJAN AT SUNDAY, NOVEMBER 15, 2009 0
COMMENTS LINKS TO THIS POST
LABELS: 9I CONCEPTS