Showing posts with label ORACLE DATABASE. Show all posts
Showing posts with label ORACLE DATABASE. Show all posts

Wednesday, January 14, 2026

Oracle DBA Interview Questions - STAR format (Situation, Task, Action, Result)

 

Basic Level Oracle DBA Interview Questions



1. What are the main responsibilities of a DBA in day-to-day operations?

Situation: As a DBA, I manage critical production databases that support business applications.
Task: My responsibility is to ensure high availability, security, and optimal performance of these databases.
Action: I monitor system health using tools like OEM and AWR reports, manage backups through RMAN, apply patches, optimize queries, and handle user access. I also proactively troubleshoot issues to prevent downtime.
Result: These actions ensure 99.9% uptime, compliance with security standards, and smooth business operations without performance bottlenecks.


2. How do you monitor and resolve performance degradation in a running database?

Situation: During a peak business cycle, users reported slow response times on critical applications.
Task: I needed to identify the root cause and restore performance quickly without impacting ongoing transactions.
Action: I analyzed AWR reports, checked v$session and v$sql for high wait events, and found inefficient queries causing contention. I tuned SQL statements, added missing indexes, and adjusted memory parameters.
Result: Query execution time dropped by 70%, and overall system performance stabilized within an hour, ensuring uninterrupted business operations.


3. Describe a situation where you improved a process or database performance.

Situation: Reporting queries were taking several minutes to execute, impacting decision-making.
Task: My goal was to optimize query performance without redesigning the application.
Action: I reviewed execution plans, introduced composite indexes, and implemented table partitioning for large datasets.
Result: Query execution time reduced from 5 minutes to under 10 seconds, improving reporting efficiency and user satisfaction.


4. How did you handle a disagreement with a team member on a DBA approach?

Situation: A colleague preferred full backups for simplicity, while I recommended incremental backups for efficiency.
Task: I needed to resolve the disagreement and choose a strategy that met compliance and performance needs.
Action: I presented recovery time objectives and compliance requirements, showing how incremental backups reduce backup windows and storage costs. We agreed on a hybrid approach—weekly full backups and daily incremental backups.
Result: This solution improved backup efficiency by 40% while meeting compliance standards, and strengthened team collaboration.


5. A production database slows down during peak hours – what steps would you take to identify and fix the issue?

Situation: A critical production database experienced severe slowdowns during peak usage.
Task: My objective was to diagnose and resolve the issue quickly to minimize business impact.
Action: I checked active sessions and wait events, analyzed execution plans, and reviewed system metrics for CPU and I/O bottlenecks. I tuned queries, added indexes, and implemented connection pooling. For long-term stability, I recommended partitioning and workload balancing.
Result: Performance improved immediately, reducing response times by 60%, and the implemented changes prevented future peak-hour slowdowns


DBA questions :- 

1. What is an Oracle database instance?
An Oracle instance is a combination of memory structures (SGA) and background processes that run on a server. It interacts with physical database files to perform operations like reading, writing, and managing data.

2. Difference between an Oracle database and an Oracle instance?

  • Database: Physical storage components such as data files, redo logs, and control files.
  • Instance: Memory structures and background processes that manage the database.
    In RAC environments, one database can have multiple instances.

3. What is the purpose of an Oracle index?
Indexes speed up data retrieval by reducing full table scans. They can be unique or non-unique, depending on the requirement.

4. What is a synonym in Oracle and why use it?
A synonym is an alias for a database object (table, view, sequence, etc.). It simplifies object access, especially across schemas, and is useful in large multi-user environments.

5. What is the purpose of a password file?
The password file stores credentials for users with SYSDBA or SYSOPER privileges, enabling authentication even when the database is down.

6. Main physical components of an Oracle database:

  • Data files: Store user and system data.
  • Redo log files: Record all changes for recovery.
  • Control files: Maintain metadata like database name, log history, and checkpoints.

7. How do you recover a database if all control files are lost?

  • Restore control files from backup using RMAN:
    RESTORE CONTROLFILE FROM 'backup_location';
  • Mount and recover the database:
    RECOVER DATABASE;
    ALTER DATABASE OPEN;
    
  • If no backup exists, recreate control files using CREATE CONTROLFILE, then recover and open with RESETLOGS.

Intermediate Level Oracle DBA Interview Questions

1. How does Oracle process an SQL statement from parsing to execution?

  • Syntax and semantic check
  • Search shared pool for existing execution plan
  • If not found, create a new plan
  • Bind variables, execute, and return results

2. Difference between hot backup and cold backup?

  • Hot backup: Taken while the database is open in ARCHIVELOG mode; users can continue working.
  • Cold backup: Taken when the database is shut down; simpler but causes downtime.

3. What are bind variables and why use them?
Bind variables hold values in SQL statements, enabling plan reuse, reducing parsing overhead, and improving performance.

4. What are deadlocks and when do they occur?
Deadlocks occur when two sessions hold locks and wait for each other. Oracle resolves this by terminating one session automatically.

5. What is row migration and its impact?
Row migration happens when an updated row no longer fits in its original block and moves to another block. This increases I/O and slows queries.

6. Difference between shared server and dedicated server configurations?

  • Dedicated: Each user gets a dedicated server process.
  • Shared: Multiple users share server processes via dispatchers; saves memory but may reduce performance under heavy load.

Advanced Level Oracle DBA Interview Questions

1. Difference between clustered and non-clustered indexes?

  • Clustered: Table data is physically sorted by the index key; only one per table.
  • Non-clustered: Stores pointers to rows; multiple allowed per table.

2. How to switch from NOARCHIVELOG to ARCHIVELOG mode?

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;

3. Key views for performance monitoring:

  • v$session – Active sessions
  • v$system_event – Wait events
  • v$sysstat – Global stats
  • v$sql – SQL performance
  • v$buffer_pool_statistics – Buffer usage

4. What is a sequence and how to set its values?
A sequence generates numeric values, often for primary keys. Use START WITH for initial value and INCREMENT BY for step size.

5. Difference between DELETE and TRUNCATE:

  • DELETE: DML, removes rows individually, supports WHERE, logs each row, can be rolled back.
  • TRUNCATE: DDL, removes all rows instantly, minimal logging, cannot be rolled back in most cases.

Experienced Level Oracle DBA Interview Questions

1. Explain ACID properties:

  • Atomicity: All-or-nothing transactions
  • Consistency: Maintains valid state
  • Isolation: Transactions run independently
  • Durability: Data persists after commit

2. How to manage user sessions and orphaned sessions?
Monitor v$session and v$process. Kill orphaned sessions using:
ALTER SYSTEM KILL SESSION 'sid,serial#';
Use profiles and RESOURCE_LIMIT for idle timeouts.

3. Tools for performance tuning:
AWR, ADDM, v$sql, wait events (v$session_wait), execution plans, and session tracing.

4. Explain RMAN backup and recovery:
RMAN automates backups (full/incremental), validates integrity, and restores missing files during recovery. Supports point-in-time recovery.

5. Methods to secure Oracle database:

  • Apply least privilege principle
  • Use roles for system privileges
  • Audit sensitive actions
  • Revoke unnecessary PUBLIC access
  • Enforce password policies via profiles



Wednesday, May 21, 2025

Backup Oracle database using rman

Backup an Oracle database using RMAN


1. Connect to RMAN

Open a terminal or command prompt and connect to RMAN as a user with the necessary privileges:


rman target /


2. Perform a Full Database Backup

At the RMAN prompt, run:


BACKUP DATABASE;


3. (Optional) Backup Archive Logs

To include archived redo logs in your backup:


BACKUP DATABASE PLUS ARCHIVELOG;


4. (Optional) Specify Backup Location

To specify a different backup location:


BACKUP DATABASE FORMAT '/backup/yourdb_%U.bkp';


5. (Optional) Backup Control File Separately



BACKUP CURRENT CONTROLFILE;



Note:


Make sure your database is in ARCHIVELOG mode for point-in-time recovery.

Schedule regular backups as per your organization’s policy.



Example 


RMAN> backup database ;


Starting backup at 21-MAY-25

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=42 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/DB1/system01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/DB1/sysaux01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/DB1/undotbs01.dbf

input datafile file number=00007 name=/u01/app/oracle/oradata/DB1/users01.dbf

channel ORA_DISK_1: starting piece 1 at 21-MAY-25

channel ORA_DISK_1: finished piece 1 at 21-MAY-25

piece handle=/u01/app/oracle/fast_recovery_area/DB1/backupset/2025_05_21/o1_mf_nnndf_TAG20250521T121502_n2vjy7y0_.bkp tag=TAG20250521T121502 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00010 name=/u01/app/oracle/oradata/DB1/pdb/sysaux01.dbf

input datafile file number=00009 name=/u01/app/oracle/oradata/DB1/pdb/system01.dbf

input datafile file number=00011 name=/u01/app/oracle/oradata/DB1/pdb/undotbs01.dbf

input datafile file number=00012 name=/u01/app/oracle/oradata/DB1/pdb/users01.dbf

channel ORA_DISK_1: starting piece 1 at 21-MAY-25

channel ORA_DISK_1: finished piece 1 at 21-MAY-25

piece handle=/u01/app/oracle/fast_recovery_area/DB1/2FACECCE69615207E0630400040AB366/backupset/2025_05_21/o1_mf_nnndf_TAG20250521T121502_n2vjzns9_.bkp tag=TAG20250521T121502 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00017 name=/u01/app/oracle/oradata/demo1/sysaux01.dbf

input datafile file number=00016 name=/u01/app/oracle/oradata/demo1/system01.dbf

input datafile file number=00018 name=/u01/app/oracle/oradata/demo1/undotbs01.dbf

channel ORA_DISK_1: starting piece 1 at 21-MAY-25

channel ORA_DISK_1: finished piece 1 at 21-MAY-25

piece handle=/u01/app/oracle/fast_recovery_area/DB1/33E6395D57264163E0630400040A2C41/backupset/2025_05_21/o1_mf_nnndf_TAG20250521T121502_n2vk0g8j_.bkp tag=TAG20250521T121502 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00006 name=/u01/app/oracle/oradata/DB1/pdbseed/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/DB1/pdbseed/system01.dbf

input datafile file number=00008 name=/u01/app/oracle/oradata/DB1/pdbseed/undotbs01.dbf

channel ORA_DISK_1: starting piece 1 at 21-MAY-25

channel ORA_DISK_1: finished piece 1 at 21-MAY-25

piece handle=/u01/app/oracle/fast_recovery_area/DB1/2FAC79D13BBE3BB3E0630400040A98FA/backupset/2025_05_21/o1_mf_nnndf_TAG20250521T121502_n2vk17nv_.bkp tag=TAG20250521T121502 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25

Finished backup at 21-MAY-25


Starting Control File and SPFILE Autobackup at 21-MAY-25

piece handle=/u01/app/oracle/fast_recovery_area/DB1/autobackup/2025_05_21/o1_mf_s_1201695424_n2vk22pc_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 21-MAY-25


RMAN>

How to configure the size of Fast Recovery Area (FRA) in Oracle database ?

Configure the size of FRA 

 


SQL>

SQL>

SQL> show parameter db_recovery


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string      /u01/app/oracle/fast_recovery_

                                                 area

db_recovery_file_dest_size           big integer 12732M

SQL>

SQL>

SQL> alter system set db_recovery_file_dest_size=12G scope=both ;


System altered.


SQL> show parameter db_recovery_file_dest_size;


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest_size           big integer 12G

SQL>

How to add a redo log member to an existing redo log group in an Oracle database | Redo log files Multiplexed

Add a redo log member to an existing redo log group in an Oracle database


SQL> select group#,status,member from v$logfile;


    GROUP# STATUS

---------- -------

MEMBER

--------------------------------------------------------------------------------

         3

/u01/app/oracle/oradata/DB1/redo03.log


         2

/u01/app/oracle/oradata/DB1/redo02.log


         1

/u01/app/oracle/oradata/DB1/redo01.log



SQL>

SQL> select group#,members,archived,status from v$log;


    GROUP#    MEMBERS ARC STATUS

---------- ---------- --- ----------------

         1          1 NO  CURRENT

         2          1 YES INACTIVE

         3          1 YES INACTIVE


SQL>

SQL> alter database add logfile member '/u01/app/oracle/oradata/DB1/redo01b.log' to group 1;


Database altered.


SQL> select member from v$logfile;


MEMBER

--------------------------------------------------------------------------------

/u01/app/oracle/oradata/DB1/redo03.log

/u01/app/oracle/oradata/DB1/redo02.log

/u01/app/oracle/oradata/DB1/redo01.log

/u01/app/oracle/oradata/DB1/redo01b.log





SQL> 



Best Practices & Notes


Always add members on different disks for redundancy.

The new log file must not exist already on disk.

All members of a group are written to simultaneously — they are identical.

Adding a member does not affect the database availability.

Tuesday, April 29, 2025

How to create pluggable database in oracle ?

 create pluggable database in oracle 




SQL> show con_name 


CON_NAME

------------------------------

CDB$ROOT

SQL> 


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

SQL> 

SQL> 

SQL> 

SQL> 




SQL> create pluggable database demo1 admin user demo1 identified by demo1

  2  file_name_convert=('/u01/app/oracle/oradata/DB1/pdbseed','/u01/app/oracle/oradata/demo1');   


Pluggable database created.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

4 DEMO1   MOUNTED






SQL> alter pluggable database demo1 open read write;


Pluggable database altered.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

4 DEMO1   READ WRITE NO

SQL> 



SQL> 

SQL>       

SQL> alter session set container=demo1;


Session altered.


SQL> show con_name 


CON_NAME

------------------------------

DEMO1

SQL> 



SQL> 

SQL> 

SQL> select name from v$pdbs;


NAME

--------------------

DEMO1


SQL> 



how to drop pluggable database in oracle ?

 Drop pluggable database in oracle


=> connect to the container database 

=> close the pluggable database 

=> unplug the pluggable database (optional)

=> drop the pluggable database 

    .if we are using the command without including datafiles , this only remove pdb not underline datafiles etc .


SQL> alter session set container =cdb$root;


Session altered.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

 2 PDB$SEED   READ ONLY  NO

 3 PDB   READ WRITE NO

 4 DEMO1   READ WRITE NO

SQL> 

SQL> alter pluggable database demo1 close immediate;


Pluggable database altered.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

 2 PDB$SEED   READ ONLY  NO

 3 PDB   READ WRITE NO

 4 DEMO1   MOUNTED

SQL> drop pluggable database demo1 including datafiles;


Pluggable database dropped.


SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

 2 PDB$SEED   READ ONLY  NO

 3 PDB   READ WRITE NO

SQL> 

How to check and list pluggable database in oracle ?

 


SQL> 

SQL> select name from v$pdbs;


NAME

--------------------

PDB$SEED

PDB


SQL> 




SQL> select pdb_name from cdb_pdbs;


PDB_NAME

--------------------

PDB

PDB$SEED





SQL> 

SQL> show pdbs


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED   READ ONLY  NO

3 PDB   READ WRITE NO

SQL> 

SQL> 



AWS IAM interview Question and Answers

  1. What is AWS IAM? Answer: AWS Identity and Access Management (IAM) is a core AWS service that enables you to securely manage access to A...