Query to check blocking sessions in Oracle database

 Query to check blocking sessions in Oracle database from v$lock:

SELECT DECODE(request,0,’Holder: ‘,’Waiter: ‘) || sid sess,
  id1,
  id2,
  lmode,
  request,
  type
FROM v$lock
WHERE (id1, id2, type) IN
  (SELECT id1, id2, type FROM v$lock WHERE request > 0
  )
ORDER BY id1,
  request;

Script to check free space and used space in Oracle Database tablespaces

select a.tablespace_name,
       a.bytes_alloc/(1024*1024) “TOTAL ALLOC (MB)”,
 a.physical_bytes/(1024*1024) “TOTAL PHYS ALLOC (MB)”,
       nvl(b.tot_used,0)/(1024*1024) “USED (MB)”,
       (nvl(b.tot_used,0)/a.bytes_alloc)*100 “% USED”
from ( select tablespace_name,
       sum(bytes) physical_bytes,
sum(decode(autoextensible,’NO’,bytes,’YES’,maxbytes)) bytes_alloc
       from dba_data_files
       group by tablespace_name ) a,
     ( select tablespace_name, sum(bytes) tot_used
       from dba_segments
group by tablespace_name ) b
where a.tablespace_name = b.tablespace_name (+)
–and   (nvl(b.tot_used,0)/a.bytes_alloc)*100 > 10
and   a.tablespace_name not in (select distinct tablespace_name from dba_temp_files)
and   a.tablespace_name not like ‘UNDO%’
order by 1
 –order by 5

How to check if Oracle Database Vault is enabled?



Below sql query can help us to identify if Oracle Database Vault is enabled or Disabled


SQL> SELECT * FROM V$OPTION WHERE PARAMETER = ‘Oracle Database Vault’;


PARAMETER                                          VALUE        CON_ID
————————————————– ——– ———-
Oracle Database Vault                              FALSE             0




Database Vault is Disabled.

What are the features of BIGFILE Tablespace in Oracle Database?

Bigfile Tablespace is introduced from Oracle 10g.A bigfile tablespace is a tablespace with a single, but very large (up to 4G blocks) datafile.


The benefits of bigfile tablespaces are the following:

A bigfile tablespace with 8K blocks can contain a 32 terabyte datafile. A bigfile tablespace with 32K blocks can contain a 128 terabyte datafile. The maximum number of datafiles in an Oracle Database is limited (usually to 64K files). Therefore, bigfile tablespaces can significantly enhance the storage capacity of an Oracle Database.



Bigfile tablespaces can reduce the number of datafiles needed for a database. 
An additional benefit is that the DB_FILES initialization parameter and MAXDATAFILES parameter of the CREATE DATABASE and CREATE CONTROLFILE statements can be adjusted to reduce the amount of SGA space required for datafile information and the size of the control file.


Bigfile tablespaces simplify database management by providing datafile transparency. 
SQL syntax for the ALTER TABLESPACE statement lets you perform operations on tablespaces, 
rather than the underlying individual datafiles.


Bigfile tablespaces are intended to be used with Automatic Storage Management (ASM) or other logical volume managers that supports striping or RAID, and dynamically extensible logical volumes.


Avoid creating bigfile tablespaces on a system that does not support striping because of negative implications for parallel query execution and RMAN backup parallelization.




Creating a Bigfile Tablespace




To create a bigfile tablespace, specify the BIGFILE keyword of the CREATE TABLESPACE statement (CREATE BIGFILE TABLESPACE …)


CREATE BIGFILE TABLESPACE bigtbs 
    DATAFILE ‘/u02/oracle/data/bigtbs01.dbf’ SIZE 50G





Identifying a Bigfile Tablespace


The following views contain a BIGFILE column that identifies a tablespace as a bigfile tablespace:


DBA_TABLESPACES


USER_TABLESPACES


V$TABLESPACE

Change Oracle Database to ArchiveLog Mode

Steps to change the database to Archivelog Mode:


1. Login to the database server. Connect to sqlplus as sysdba


$sqlplus / as sysdba


2. Shutdown the database


SQL> shutdown immediate


3. Take a full database Backup (Cold Backup in this case)


4. Startup the database in mount stage


SQL> startup mount


5. Enable Archivelog mode


SQL> alter database archivelog;


6. Open the Database.


SQL> Alter database open;


7. Verify the changes.


SQL> archive log list;

What is the use of MMON background process in Oracle Database?

MMON (Manageability Monitor)


MMON (Manageability Monitor) is a background process introduced in Oracle 10g. It gathers memory statistics (snapshots) and stores this information in the AWR (automatic workload repository). MMON is also responsible for issuing alerts for metrics that exceed their thresholds.





Oracle Recovery Manager Features: BACKUP AS COPY

What is the advantage backup as copy feature in RMAN?

RMAN(Recovery Manager) utility creates backup in the form of backupsets or backup pieces by default.RMAN utility also allows other method which is similar to user managed hot backup. It can be acheived using ‘BACKUP AS COPY’ command.Using “Backup as Copy” RMAN creates backup in the form of image copies. However, we do not need to put the database in begin backup/end backup mode as in Conventional Hot Backup.

Syntax for Datafile Backup using Backup as copy:

RMAN> backup as copy datafile 1 format ‘/backup/data/datafile01.dbf’ ;



Another advantage of this feature is that it allows to create image copy of control file.

 RMAN> backup as copy current controlfile format ‘F:CntrlFile_Bkp.ctl’;  



How do we identify backups taken  as Image copies using RMAN?


Use “LIST COPY” Command. “LIST BACKUP” only gives a list of backup sets which were created using default RMAN backup Methos.

Syntax:

RMAN> LIST COPY;

Oracle RMAN (Recovery Manager) Concepts

What is the difference between obsolete and expired Backup in RMAN?

Obsolete Backup: Backup pieces or backup sets which are not needed for recovery.
We can use the REPORT OBSOLETE command to list the obsolete backups and DELETE OBSOLETE command to delete the obsolete backup.

Expired Backup:When the CROSSCHECK command is used to determine whether backups recorded in the repository still exist on disk or tape, if RMAN cannot locate the backups, then it updates their records in the RMAN repository to EXPIRED status.We can then use the DELETE EXPIRED command to remove records of expired backups from the RMAN repository.