I will share all Oracle DBA Scripts ( Oracle RAC, Dataguard, Performance Tuning, Monitoring and etc.. ) in this tutorial series.
Oracle DBA ( Database Administrator ) needs useful scripts to monitor, analyze and check Oracle database for routine database operations and monitoring.
Oracle DBA Scripts All in One post will be updated with new Oracle DBA Scripts.
Before Oracle DBA Scripts, If you don’t know Oracle database and want to learn, click following link to start learning Oracle database with this tutorial.
You can check RMAN Backup job details status with following script.
SELECT TO_CHAR (start_time, 'DD-MM-YYYY HH24:MI:SS') start_time, input_type, status, ROUND (elapsed_seconds / 3600, 1) time_hr,INPUT_BYTES/1024/1024/1024 IN_GB,OUTPUT_BYTES/1024/1024/1024 OUT_GB ,OUTPUT_DEVICE_TYPE FROM v$rman_backup_job_details WHERE START_TIME > SYSDATE - 3 ORDER BY start_time DESC;
If you start long operations such as RMAN Backup and Datapump Export in Oracle database, probably you want to see progress of these operations.
You can see and monitor RMAN Backup progress with following script.
SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK, ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE" FROM V$SESSION_LONGOPS WHERE OPNAME LIKE 'RMAN%' AND OPNAME NOT LIKE '%aggregate%' AND TOTALWORK != 0 AND SOFAR <> TOTALWORK order by 6 desc;
You can monitor Datapump Export ,Import and other long operations with following script.
SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK, ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE" FROM V$SESSION_LONGOPS WHERE OPNAME NOT LIKE '%aggregate%' AND TOTALWORK != 0 AND SOFAR <> TOTALWORK order by 6 desc;
The summary report of the backups can be listed with the following command.
RMAN> LIST BACKUP SUMMARY;
you can use following command to see the backup of database.
RMAN> List backup of database;
you can use following command to see only the backup of archivelogs.
RMAN> LIST BACKUP OF ARCHIVELOG ALL;
The following query can be used to query controlfile backups .
RMAN> list backup of controlfile;
The following query can be used to query datafile backups .
RMAN> LIST BACKUP OF DATAFILE 1;
When redo log files are archived, then redo log files are overwritten with new redo data. But archivelogs are not deleted or automatically if you don’t schedule any deletion job.
You can delete all archivelogs with following query.
RMAN> delete archivelog all;
You can delete archivelogs until spesific time ( until time 1 day ago ) like following query.
RMAN> delete archivelog until time 'sysdate -1';
You can delete all archivelog without prompt ( yes or no question ) and with force option.
RMAN> delete noprompt force archivelog all;
You can delete archivelog which is backed up 1 times to Tape. you can change 1 times with 2 or 3.
RMAN> delete archivelog all backed up 1 times to SBT_TAPE;
You can delete archivelog which is backed up 1 times to Disk.
RMAN> delete archivelog all backed up 1 times to DISK;
You can delete archivelog until spesific sequence option.
RMAN> delete archivelog until sequence 9310 thread 1;
You can access the third Oracle DBA scripts related to Blocking Sessions and Lock Kill Scripts with following link.
Do you want to learn Oracle Database Performance Tuning detailed, then read the following articles.
1,219 views last month, 10 views today