My Youtube Channel

Please Subscribe

Flag of Nepal

Built in OpenGL

Word Cloud in Python

With masked image

Tuesday, March 24, 2026

Oracle DBA Interview Questions and Answers (2026 Guide)

Oracle DBA Interview Questions and Answers (2026 Guide)

Preparing for an Oracle DBA interview? Whether you're a beginner or an experienced professional working with Oracle Database, this guide covers the most commonly asked questions across key areas:

  • Tablespaces

  • Indexes

  • Performance Tuning

  • Backups (RMAN)

  • RAC Basics


📦 1. Tablespaces

❓ What is a tablespace?

A tablespace is a logical storage unit in Oracle used to store database objects like tables and indexes.


❓ Types of tablespaces?

  • SYSTEM → stores data dictionary

  • SYSAUX → auxiliary metadata

  • USERS → default user data

  • UNDO → undo information

  • TEMP → temporary operations


❓ Difference between bigfile and smallfile tablespace?

FeatureBigfileSmallfile
DatafilesSingleMultiple
SizeVery largeModerate
ManagementSimplerFlexible

❓ How to check tablespace size?

SELECT tablespace_name, SUM(bytes)/1024/1024 MB
FROM dba_data_files
GROUP BY tablespace_name;

❓ What happens when tablespace is full?

  • Inserts/updates fail

  • Errors like ORA-01653

  • Application impact


📊 2. Indexes

❓ What is an index?

An index improves query performance by allowing faster data retrieval.


❓ Types of indexes?

  • B-Tree Index (default)

  • Bitmap Index

  • Unique Index

  • Composite Index

  • Function-based Index


❓ When should you not use an index?

  • Small tables

  • Columns with low selectivity

  • Frequent DML operations


❓ How to find unused indexes?

SELECT * FROM v$object_usage WHERE used = 'NO';

❓ Difference between B-Tree and Bitmap index?

FeatureB-TreeBitmap
Use CaseOLTPData warehouse
DMLFastSlow
CardinalityHighLow

🚀 3. Performance Tuning

❓ What is performance tuning?

Process of improving database efficiency by optimizing SQL, memory, and resources.


❓ How to identify slow SQL?

  • V$SQL

  • V$SQLAREA

  • AWR reports


❓ What is an execution plan?

It shows how Oracle executes a SQL query.

EXPLAIN PLAN FOR SELECT * FROM emp;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);

❓ What causes slow queries?

  • Missing indexes

  • Full table scans

  • Poor joins

  • Outdated statistics


❓ What is bind variable?

A placeholder used in SQL to improve parsing efficiency.


💾 4. Backup and Recovery (RMAN)

❓ What is RMAN?

Recovery Manager is Oracle’s tool for backup and recovery.


❓ Types of backups?

  • Full backup

  • Incremental backup

  • Archive log backup


❓ Difference between Level 0 and Level 1?

  • Level 0 → full backup

  • Level 1 → incremental changes


❓ What is ARCHIVELOG mode?

It allows recovery up to the last committed transaction.


❓ How to take backup?

BACKUP DATABASE PLUS ARCHIVELOG;

❓ How to validate backup?

RESTORE DATABASE VALIDATE;

🧩 5. RAC (Real Application Clusters) Basics

❓ What is RAC?

Oracle RAC allows multiple instances to access a single database.


❓ Benefits of RAC?

  • High availability

  • Load balancing

  • Scalability


❓ What is CRS?

Cluster Ready Services manages cluster resources.


❓ What is SCAN?

Single Client Access Name simplifies client connectivity.


❓ What is interconnect?

Private network used for communication between nodes.


🧠 6. Scenario-Based Questions

❓ Tablespace full issue?

Answer:

  • Add datafile

  • Resize existing file

  • Enable autoextend


❓ Database running slow suddenly?

Answer:

  • Check AWR report

  • Identify top SQL

  • Check CPU, I/O


❓ Recovery after accidental delete?

Answer:

  • Use RMAN restore

  • Flashback (if enabled)


❓ High CPU usage?

Answer:

  • Identify SQL from V$SQL

  • Tune query

  • Add indexes


🎯 7. Tips to Crack Oracle DBA Interviews

✅ Be strong in basics

✅ Practice SQL queries

✅ Understand real scenarios

✅ Learn RMAN commands

✅ Know RAC architecture basics


📌 Conclusion

An Oracle DBA interview for roles involving Oracle Database typically focuses on:

  • Storage (tablespaces)

  • Performance (SQL tuning)

  • Recovery (RMAN)

  • High availability (RAC)

Mastering these areas with practical examples will give you a strong edge in 2026 interviews.


🚀 Bonus: What Interviewers Expect

  • Clear understanding of concepts

  • Hands-on experience

  • Problem-solving approach

  • Confidence in troubleshooting

How to Identify Slow SQL Queries in Oracle (Practical Guide for Performance Tuning)

 

How to Identify Slow SQL Queries in Oracle (Practical Guide for Performance Tuning)

Performance tuning is one of the most valuable skills when working with Oracle Database. Slow SQL queries can degrade application performance, increase CPU usage, and frustrate users.

In this guide, we’ll cover how to identify slow SQL using:

  • V$SQL

  • V$SQLAREA

  • AWR Reports

  • Simple and effective tuning ideas


🔍 1. Using V$SQL to Find Slow Queries

The V$SQL view contains detailed statistics about SQL statements currently in the shared pool.


✅ Find Top Slow Queries by Elapsed Time

SELECT 
    sql_id,
    executions,
    elapsed_time/1000000 AS elapsed_sec,
    cpu_time/1000000 AS cpu_sec,
    disk_reads,
    buffer_gets,
    sql_text
FROM 
    v$sql
ORDER BY 
    elapsed_time DESC
FETCH FIRST 10 ROWS ONLY;

📌 Key Columns Explained

  • elapsed_time → total execution time

  • cpu_time → CPU usage

  • disk_reads → physical I/O (slow operations)

  • buffer_gets → logical reads

  • executions → how many times query ran

👉 Focus on:

  • High elapsed time

  • High disk reads

  • High buffer gets


🎯 Find Slow Queries Per Execution

SELECT 
    sql_id,
    executions,
    elapsed_time / DECODE(executions,0,1,executions) / 1000000 AS avg_time_sec,
    sql_text
FROM 
    v$sql
ORDER BY 
    avg_time_sec DESC;

👉 This helps identify queries that are slow individually (not just frequent ones).


📊 2. Using V$SQLAREA (Aggregated View)

V$SQLAREA provides aggregated statistics for SQL statements.


✅ Top Queries by Resource Usage

SELECT 
    sql_id,
    executions,
    buffer_gets,
    disk_reads,
    elapsed_time/1000000 AS elapsed_sec,
    sql_text
FROM 
    v$sqlarea
ORDER BY 
    buffer_gets DESC
FETCH FIRST 10 ROWS ONLY;

📌 When to Use V$SQLAREA

  • To identify heavy queries overall

  • When multiple executions are involved

  • For workload-level analysis


📈 3. Using AWR Reports (Advanced Method)

🔍 What is AWR?

AWR (Automatic Workload Repository) stores historical performance data in Oracle Database.


🛠️ Generate AWR Report

@$ORACLE_HOME/rdbms/admin/awrrpt.sql

📊 Key Sections in AWR Report

🔥 Top SQL by Elapsed Time

  • Shows queries consuming most time

💽 Top SQL by Disk Reads

  • Identifies I/O-heavy queries

🧠 Top SQL by CPU Time

  • CPU-intensive SQL


📌 What to Look For

  • High elapsed time SQL

  • SQL with high executions

  • SQL with high I/O

👉 AWR is best for:

  • Historical analysis

  • Production troubleshooting

  • Identifying trends


🚨 4. Common Signs of Slow SQL

  • High response time

  • High CPU usage

  • Excessive disk reads

  • Full table scans

  • Long-running sessions


🛠️ 5. Simple SQL Tuning Ideas


✅ 1. Use Proper Indexes

CREATE INDEX idx_emp_name ON emp(name);

👉 Helps avoid full table scans


✅ 2. Avoid SELECT *

-- Bad
SELECT * FROM employees;

-- Good
SELECT id, name FROM employees;

👉 Reduces unnecessary data retrieval


✅ 3. Use Bind Variables

SELECT * FROM emp WHERE emp_id = :id;

👉 Improves parsing efficiency


✅ 4. Check Execution Plan

EXPLAIN PLAN FOR 
SELECT * FROM emp WHERE id = 100;

SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);

👉 Understand how Oracle executes query


✅ 5. Reduce Full Table Scans

  • Add indexes

  • Use selective conditions


✅ 6. Optimize Joins

  • Use proper join conditions

  • Avoid Cartesian joins


✅ 7. Gather Statistics

EXEC DBMS_STATS.GATHER_SCHEMA_STATS('HR');

👉 Helps optimizer choose better plans


🧪 6. Real-World Example

Problem Query

SELECT * FROM orders WHERE customer_id = 101;

Issue

  • No index on customer_id

  • Full table scan


Solution

CREATE INDEX idx_orders_cust ON orders(customer_id);

👉 Result:

  • Query becomes significantly faster


⚖️ V$SQL vs V$SQLAREA vs AWR

FeatureV$SQLV$SQLAREAAWR
Data TypeReal-timeAggregatedHistorical
ScopeIndividual SQLCombined SQLSystem-wide
Use CaseImmediate tuningWorkload analysisDeep performance analysis

📌 Conclusion

Identifying slow SQL in Oracle Database involves a combination of:

  • Real-time views (V$SQL, V$SQLAREA)

  • Historical analysis (AWR Reports)

Once identified, applying simple tuning techniques like indexing, query optimization, and statistics gathering can dramatically improve performance.


🚀 Next Topics You Can Cover

Since you're building performance-focused content, you can also write about:

  • SQL Execution Plans deep dive

  • Index types in Oracle

  • Wait events and session tuning

  • ASH vs AWR

Just tell me if you want those ready 👍

How to Drop Tablespace Safely in Oracle (Complete Practical Guide)

 

How to Drop Tablespace Safely in Oracle (Complete Practical Guide)

Managing storage in Oracle Database often involves cleaning up unused tablespaces. However, dropping a tablespace is a critical and irreversible operation if not handled properly.

This guide explains:

  • DROP TABLESPACE syntax

  • Difference between INCLUDING CONTENTS and KEEP DATAFILES

  • Risks and safety precautions

  • Real-world practical steps


📦 1. What is a Tablespace?

A tablespace is a logical storage unit in Oracle that contains datafiles. It stores:

  • Tables

  • Indexes

  • LOBs

  • Other database objects

Dropping a tablespace removes all objects stored inside it.


⚠️ 2. Basic DROP TABLESPACE Syntax

DROP TABLESPACE tablespace_name;

👉 This works only if the tablespace is empty


🔥 3. Drop Tablespace with Contents

✅ Syntax

DROP TABLESPACE tablespace_name INCLUDING CONTENTS;

📌 What it does:

  • Deletes all objects inside the tablespace

  • Removes metadata from data dictionary

  • Does NOT delete physical datafiles

👉 Use this when you want to remove logical structures but keep files on disk.


💣 4. Drop Tablespace Including Datafiles

✅ Syntax

DROP TABLESPACE tablespace_name INCLUDING CONTENTS AND DATAFILES;

📌 What it does:

  • Deletes all objects

  • Deletes datafiles from OS

  • Completely frees disk space

⚠️ This is irreversible


🧊 5. Keep Datafiles Option

✅ Syntax

DROP TABLESPACE tablespace_name INCLUDING CONTENTS KEEP DATAFILES;

📌 What it does:

  • Removes tablespace from database

  • Leaves datafiles untouched on disk

👉 Useful when:

  • You want to reuse files

  • You need backup/forensic analysis


⚖️ Summary of Options

CommandObjects RemovedDatafiles Removed
DROP TABLESPACE
INCLUDING CONTENTS
INCLUDING CONTENTS AND DATAFILES
KEEP DATAFILES

🚨 6. Risks of Dropping Tablespace

Dropping a tablespace can cause serious issues if not planned properly:

❌ Data Loss

All tables and indexes inside will be permanently deleted.

❌ Application Failure

If application depends on that tablespace → system may break.

❌ Foreign Key Dependencies

Objects in other tablespaces may reference it.

❌ Backup Impact

If not backed up, recovery becomes impossible.


🛡️ 7. Safety Checklist Before Dropping

✅ 1. Check Tablespace Contents

SELECT owner, segment_name, segment_type
FROM dba_segments
WHERE tablespace_name = 'USERS';

✅ 2. Check Datafiles

SELECT file_name
FROM dba_data_files
WHERE tablespace_name = 'USERS';

✅ 3. Check Default Tablespace Users

SELECT username
FROM dba_users
WHERE default_tablespace = 'USERS';

👉 Change users before dropping:

ALTER USER username DEFAULT TABLESPACE new_tablespace;

✅ 4. Take Backup (VERY IMPORTANT)

Using RMAN:

BACKUP TABLESPACE users;

✅ 5. Ensure No Active Usage

SELECT * FROM v$sort_usage WHERE tablespace = 'USERS';

🧪 8. Practical Example (Step-by-Step)

🎯 Scenario: Drop tablespace OLD_DATA


Step 1: Verify contents

SELECT COUNT(*) FROM dba_segments 
WHERE tablespace_name = 'OLD_DATA';

Step 2: Backup

BACKUP TABLESPACE old_data;

Step 3: Drop safely

DROP TABLESPACE old_data INCLUDING CONTENTS AND DATAFILES;

Step 4: Verify removal

SELECT * FROM dba_tablespaces 
WHERE tablespace_name = 'OLD_DATA';

🧠 9. Best Practices

✅ Always backup before dropping

✅ Never drop SYSTEM or SYSAUX tablespaces

✅ Avoid dropping USERS tablespace in production

✅ Check dependencies carefully

✅ Use KEEP DATAFILES if unsure

✅ Perform during maintenance window


🔍 10. Common Mistakes to Avoid

❌ Dropping without checking users
❌ Forgetting backup
❌ Confusing KEEP DATAFILES vs AND DATAFILES
❌ Dropping active tablespace
❌ Ignoring application impact


📌 Conclusion

Dropping a tablespace in Oracle Database is a powerful but risky operation. Understanding the difference between:

  • INCLUDING CONTENTS

  • AND DATAFILES

  • KEEP DATAFILES

is essential for safe database administration.

Always follow a structured approach: Check → Backup → Drop → Verify to avoid irreversible data loss.


Oracle Backup Strategy for Beginners (Complete Guide with Examples)

 

Oracle Backup Strategy for Beginners (Complete Guide with Examples)

If you're starting your journey as a DBA working with Oracle Database, understanding backups is one of the most critical skills you must develop. A good backup strategy ensures your data is safe from failures, corruption, or human errors.

This guide explains RMAN basics, Full vs Incremental backups, and ARCHIVELOG mode in a clear, practical way.


📦 1. What is RMAN?

RMAN (Recovery Manager) is Oracle’s built-in backup and recovery tool.

🔑 Key Features of RMAN:

  • Performs hot (online) backups while database is running

  • Supports incremental backups

  • Automatically tracks backups

  • Validates and detects corruption

  • Works with ARCHIVELOG mode


🛠️ Basic RMAN Commands

Connect to RMAN

rman target /

Take a Full Database Backup

BACKUP DATABASE;

Backup with Format

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

Backup Control File

BACKUP CURRENT CONTROLFILE;

💾 2. Full Backup vs Incremental Backup

Understanding backup types is essential for designing an efficient strategy.


🔵 Full Backup

A Full Backup copies the entire database.

✅ Example

BACKUP DATABASE PLUS ARCHIVELOG;

📌 Advantages:

  • Simple to restore

  • Complete snapshot of database

❌ Disadvantages:

  • Takes more time

  • Requires more storage


🟡 Incremental Backup

An Incremental Backup only backs up changed data blocks.


🔹 Level 0 (Base Backup)

BACKUP INCREMENTAL LEVEL 0 DATABASE;

👉 Works like a full backup


🔹 Level 1 Incremental

BACKUP INCREMENTAL LEVEL 1 DATABASE;

👉 Backs up only changes since last Level 0 or Level 1


📊 Types of Incremental Backups:

TypeDescription
DifferentialChanges since last Level 1
CumulativeChanges since last Level 0

📌 Advantages:

  • Faster backups

  • Less storage usage

❌ Disadvantages:

  • Restore process is more complex

  • Requires all backup pieces


🔄 Example Strategy

-- Weekly full backup
BACKUP INCREMENTAL LEVEL 0 DATABASE;

-- Daily incremental backup
BACKUP INCREMENTAL LEVEL 1 DATABASE;

🔁 3. ARCHIVELOG Mode Explained

🔍 What is ARCHIVELOG Mode?

In Oracle Database, ARCHIVELOG mode means:

  • All changes in redo logs are archived

  • Enables point-in-time recovery


🔥 Why ARCHIVELOG Mode is Important

Without ARCHIVELOG:

  • You can only restore to last backup

  • Data loss is unavoidable

With ARCHIVELOG:

  • You can recover up to the last committed transaction


🔎 Check ARCHIVELOG Mode

SELECT log_mode FROM v$database;

🔄 Enable ARCHIVELOG Mode

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

📦 Backup Archive Logs

BACKUP ARCHIVELOG ALL;

Or combined:

BACKUP DATABASE PLUS ARCHIVELOG;

🚨 Why Backups Matter (Real Scenarios)

1. 💥 System Crash

Recover database after hardware failure

2. 🧑‍💻 Accidental Data Deletion

Restore table or database to earlier time

3. 🦠 Data Corruption

Recover corrupted blocks using RMAN

4. 🔐 Disaster Recovery

Restore database on another server


🧠 Best Practices for Beginners

✅ Follow 3-2-1 Rule

  • 3 copies of data

  • 2 different storage types

  • 1 offsite backup

✅ Automate Backups

Use cron jobs or scheduler

✅ Validate Backups

RESTORE DATABASE VALIDATE;

✅ Monitor Backup Status

LIST BACKUP;

✅ Delete Old Backups

DELETE OBSOLETE;

🧪 Sample Beginner Backup Plan

FrequencyBackup Type
DailyLevel 1 Incremental
WeeklyLevel 0 (Full)
HourlyArchive Log Backup

📌 Conclusion

A strong backup strategy in Oracle Database revolves around:

  • Using RMAN effectively

  • Combining Full and Incremental backups

  • Enabling ARCHIVELOG mode for complete recovery

Mastering these basics ensures you are prepared for real-world database failures and recovery scenarios.


How to Find the Largest Tables in an Oracle Database ?

 

How to Find the Largest Tables in an Oracle Database

Managing database storage is a critical responsibility for DBAs, especially when working with enterprise systems powered by Oracle Database. Over time, tables can grow significantly, impacting performance, backup time, and maintenance operations.

In this guide, we’ll explore how to identify the largest tables using DBA_SEGMENTS and DBA_TABLES, along with understanding why large tables can affect performance.


🔍 1. Using DBA_SEGMENTS to Find Largest Tables

The DBA_SEGMENTS view provides information about storage used by database segments (tables, indexes, etc.).

✅ Query to Find Largest Tables

SELECT 
    owner,
    segment_name AS table_name,
    ROUND(SUM(bytes) / 1024 / 1024, 2) AS size_mb
FROM 
    dba_segments
WHERE 
    segment_type = 'TABLE'
GROUP BY 
    owner, segment_name
ORDER BY 
    size_mb DESC;

📌 Explanation

  • segment_type = 'TABLE' → filters only table segments

  • bytes → actual storage used

  • SUM(bytes) → total size of each table

  • Converted into MB for readability

  • Sorted in descending order → largest tables on top

👉 This is the most accurate method because it shows real disk usage.


🔍 2. Using DBA_TABLES to Estimate Table Size

The DBA_TABLES view contains metadata about tables, including row counts and block usage.

✅ Query to Estimate Table Size

SELECT 
    owner,
    table_name,
    num_rows,
    blocks,
    ROUND((blocks * 8) / 1024, 2) AS size_mb
FROM 
    dba_tables
WHERE 
    blocks IS NOT NULL
ORDER BY 
    size_mb DESC;

📌 Explanation

  • num_rows → approximate number of rows

  • blocks → number of data blocks used

  • Block size assumed as 8KB (default, may vary)

  • Size is estimated, not exact

⚠️ Important:
This method depends on statistics. If stats are outdated, results may be inaccurate.

👉 To refresh statistics:

EXEC DBMS_STATS.GATHER_SCHEMA_STATS('SCHEMA_NAME');

⚖️ DBA_SEGMENTS vs DBA_TABLES

FeatureDBA_SEGMENTSDBA_TABLES
Accuracy✅ Exact storage⚠️ अनुमान (estimated)
Includes unused spaceYesNo
Depends on statsNoYes
Best forStorage analysisLogical table analysis

🚨 Why Large Tables Impact Performance

Large tables don’t just consume space—they can significantly affect database performance in several ways:

1. 🔄 Slower Full Table Scans

Queries without proper indexes may scan millions of rows, increasing execution time.

2. 📉 Index Maintenance Overhead

Indexes on large tables:

  • Take longer to rebuild

  • Increase DML (INSERT/UPDATE/DELETE) cost

3. 💾 Increased I/O Operations

More data = more disk reads → higher latency.

4. 🕒 Longer Backup and Recovery Time

Large tables:

  • Increase RMAN backup size

  • Slow down restore operations

5. 🔐 Locking and Concurrency Issues

Heavy operations on large tables can:

  • Cause locking contention

  • Impact multiple users simultaneously

6. 📊 Statistics and Optimization Challenges

Optimizer may choose inefficient execution plans if:

  • Stats are stale

  • Data distribution is uneven


🛠️ Best Practices for Handling Large Tables

  • ✅ Use partitioning (range, list, hash)

  • ✅ Create proper indexes

  • ✅ Regularly gather statistics

  • ✅ Archive or purge old data

  • ✅ Use compression where applicable

  • ✅ Monitor growth trends


📌 Conclusion

Finding large tables is essential for proactive database management. While DBA_SEGMENTS gives you the most accurate storage usage, DBA_TABLES provides useful logical insights when statistics are up-to-date.

Understanding and managing large tables helps improve performance, reduce storage costs, and ensure smoother database operations.


Friday, March 20, 2026

How to Check Default Tablespace of a User in Oracle ?


## 📘 What Are Data Dictionary Tables?


In Oracle, **data dictionary tables** are system-owned tables that store metadata about the database.


They contain information such as:


* Users and roles

* Tables and indexes

* Tablespaces

* Privileges and permissions


These tables are owned by the `SYS` user and are accessed through **views** like:


* `DBA_USERS`

* `ALL_USERS`

* `USER_USERS`


👉 Think of them as a **database about your database**.


---


## 🔍 Query to Check Default Tablespace of a User


The most common way to check a user’s default tablespace is using the `DBA_USERS` view.


### ✅ Basic Query


```sql

SELECT username, default_tablespace

FROM dba_users

WHERE username = 'YOUR_USERNAME';

```


🔹 Replace `'YOUR_USERNAME'` with the actual username (in uppercase).


---


### ✅ Example


```sql

SELECT username, default_tablespace

FROM dba_users

WHERE username = 'HR';

```


**Output:**


```

USERNAME   DEFAULT_TABLESPACE

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

HR         USERS

```


---


### ⚠️ Note


* You need **DBA privileges** to query `DBA_USERS`.

* If you don’t have access, use:


```sql

SELECT username, default_tablespace

FROM user_users;

```


or


```sql

SELECT username, default_tablespace

FROM all_users;

```


---


## 🧊 What Is Default Tablespace?


A **default tablespace** is the location where a user’s objects are stored if no tablespace is explicitly specified.


### 📌 Example:


```sql

CREATE TABLE employees (

  id NUMBER,

  name VARCHAR2(100)

);

```


👉 This table will be created in the user’s **default tablespace**.


---


## 🔄 Temporary Tablespace Explained


A **temporary tablespace** is used for **temporary operations**, such as:


* Sorting data

* Hash joins

* Global temporary tables


---


### 🔍 Check Temporary Tablespace


```sql

SELECT username, temporary_tablespace

FROM dba_users

WHERE username = 'HR';

```


---


## ⚖️ Default vs Temporary Tablespace


| Feature          | Default Tablespace       | Temporary Tablespace              |

| ---------------- | ------------------------ | --------------------------------- |

| Purpose          | Stores permanent objects | Used for temporary operations     |

| Data Persistence | Permanent                | Temporary (cleared automatically) |

| Example Use      | Tables, indexes          | Sorting, joins                    |

| Storage Type     | Datafiles                | Tempfiles                         |


---


## 🧠 Key Differences Explained


* **Default Tablespace**


  * Stores actual database objects

  * Data remains until explicitly deleted


* **Temporary Tablespace**


  * Used only during query execution

  * Data disappears after operation completes


---


## 🚀 Pro Tips


✔ Always assign a **dedicated default tablespace** for users instead of using `SYSTEM`


✔ Monitor tablespace usage regularly to avoid issues like space exhaustion


✔ Use separate temporary tablespaces for heavy workloads to improve performance


---


## 🧾 Conclusion


Understanding default and temporary tablespaces is essential for efficient database management in Oracle. By using simple queries on data dictionary views like `DBA_USERS`, you can quickly identify where user data is stored and how temporary operations are handled.


---


If you want, I can also:


* Add **images/diagrams for your blog**

* Create **SEO title + tags**

* Suggest **related Oracle topics** to grow your blog traffic


Sunday, March 15, 2026

Oracle Tablespace Full Error ORA-01653 – Complete Explanation & Fix


The ORA-01653 error occurs when Oracle cannot allocate additional space for a segment (table, index, etc.) inside a tablespace.

Typical error message:

ORA-01653: unable to extend table <schema.table_name> by <n> in tablespace <tablespace_name>

This means Oracle tried to allocate a new extent for the object but the tablespace did not have enough free space.


1. What ORA-01653 Means

Oracle stores data in the following hierarchy:

Tablespace
   → Datafile
       → Segment (table/index)
           → Extent
               → Block

When a table grows, Oracle allocates extents.

If:

  • No free space exists in the tablespace

  • Datafiles cannot grow

  • Autoextend is disabled

Oracle raises:

ORA-01653: unable to extend segment

Example:

ORA-01653: unable to extend table HR.EMPLOYEES by 128 in tablespace USERS

Meaning:

Oracle tried to allocate 128 blocks but failed.


2. Why Tablespace Becomes Full

Several reasons can cause this error.

1. Datafiles reached maximum size

A tablespace consists of datafiles.

If a datafile reaches its maxsize, Oracle cannot extend it further.

Example:

users01.dbf = 10GB maxsize

Once full → ORA-01653 occurs.


2. Autoextend is OFF

If autoextend is disabled, Oracle cannot automatically increase datafile size.

Check example:

AUTOEXTEND OFF

Then the file stops growing.


3. Tables growing very fast

Common causes:

  • Large inserts

  • Batch jobs

  • ETL loads

  • Logging tables

  • Archival tables

Example:

INSERT INTO big_table SELECT * FROM source_table;

This may fill tablespace quickly.


4. Large index creation

Indexes require large temporary space.

Example:

CREATE INDEX idx1 ON huge_table(column1);

Index creation may trigger ORA-01653.


5. Fragmented free space

Sometimes tablespace has free space but not contiguous extents.

Oracle cannot allocate the required extent.


6. Temp tablespace full

If the error occurs during sorting:

ORA-01652: unable to extend temp segment

This is similar but occurs in TEMP tablespace.


3. Queries to Check Tablespace Usage

Before fixing, we must analyze usage.


Query 1 — Tablespace Size and Free Space

SELECT
    df.tablespace_name,
    ROUND(df.total_mb) total_mb,
    ROUND(fs.free_mb) free_mb,
    ROUND((df.total_mb - fs.free_mb)) used_mb,
    ROUND((fs.free_mb / df.total_mb) * 100,2) free_percent
FROM
    (SELECT tablespace_name,
            SUM(bytes)/1024/1024 total_mb
     FROM dba_data_files
     GROUP BY tablespace_name) df
JOIN
    (SELECT tablespace_name,
            SUM(bytes)/1024/1024 free_mb
     FROM dba_free_space
     GROUP BY tablespace_name) fs
ON df.tablespace_name = fs.tablespace_name
ORDER BY free_percent;

Output example:

TABLESPACETOTAL_MBFREE_MBUSED_MBFREE%
USERS10240100101400.9

This indicates the tablespace is nearly full.


Query 2 — Datafile Size

SELECT
file_name,
tablespace_name,
bytes/1024/1024 MB,
autoextensible,
maxbytes/1024/1024 MAX_MB
FROM dba_data_files;

Shows:

  • file size

  • max size

  • autoextend status


Query 3 — Free Space per Tablespace

SELECT
tablespace_name,
SUM(bytes)/1024/1024 FREE_MB
FROM dba_free_space
GROUP BY tablespace_name;

Query 4 — Largest Segments

Useful to identify which object is consuming space.

SELECT
owner,
segment_name,
segment_type,
tablespace_name,
bytes/1024/1024 MB
FROM dba_segments
ORDER BY bytes DESC;

Query 5 — Datafile Usage %

SELECT
file_name,
bytes/1024/1024 SIZE_MB,
maxbytes/1024/1024 MAX_MB,
(autoextensible)
FROM dba_data_files;

4. Solutions to Fix ORA-01653

There are multiple fixes depending on the situation.


Solution 1 — Add New Datafile (Best Solution)

Add another datafile to the tablespace.

ALTER TABLESPACE users
ADD DATAFILE '/u01/oradata/users02.dbf'
SIZE 5G;

Example:

ALTER TABLESPACE USERS
ADD DATAFILE '/data/oracle/users02.dbf'
SIZE 10G AUTOEXTEND ON;

Advantages:

  • Safest solution

  • No downtime

  • Immediate fix


Solution 2 — Resize Existing Datafile

If disk space is available, increase file size.

ALTER DATABASE DATAFILE
'/u01/oradata/users01.dbf'
RESIZE 8G;

Example:

ALTER DATABASE DATAFILE
'/data/oracle/users01.dbf'
RESIZE 20G;

Note:

Resize must be larger than current used space.


Solution 3 — Enable Autoextend

If autoextend is disabled, enable it.

ALTER DATABASE DATAFILE
'/u01/oradata/users01.dbf'
AUTOEXTEND ON;

Better version:

ALTER DATABASE DATAFILE
'/u01/oradata/users01.dbf'
AUTOEXTEND ON
NEXT 100M
MAXSIZE 20G;

Meaning:

Grow by 100MB each time
Maximum 20GB

Solution 4 — Add Multiple Datafiles

Large production systems often use multiple files.

ALTER TABLESPACE users
ADD DATAFILE '/data/users03.dbf' SIZE 5G AUTOEXTEND ON;

Solution 5 — Clean Unused Objects

Sometimes old objects consume space.

Find large objects:

SELECT
owner,
segment_name,
bytes/1024/1024 MB
FROM dba_segments
ORDER BY bytes DESC;

Then:

DROP TABLE old_table;

Or:

TRUNCATE TABLE old_table;

Solution 6 — Rebuild Index

Indexes may occupy large space.

ALTER INDEX index_name REBUILD;

Or move to different tablespace.

ALTER INDEX index_name
REBUILD TABLESPACE index_ts;

Solution 7 — Shrink Segments

If ASSM enabled:

ALTER TABLE table_name ENABLE ROW MOVEMENT;

ALTER TABLE table_name SHRINK SPACE;

Example Real Scenario

Error:

ORA-01653: unable to extend table CDR.CALL_RECORDS

Diagnosis:

SELECT tablespace_name, SUM(bytes)/1024/1024 free_mb
FROM dba_free_space
GROUP BY tablespace_name;

Result:

CDR_TS free space = 10 MB

Fix:

ALTER TABLESPACE CDR_TS
ADD DATAFILE '/data/cdr02.dbf'
SIZE 10G AUTOEXTEND ON;

Problem solved.


Best Practices to Prevent ORA-01653

1. Enable Autoextend

AUTOEXTEND ON NEXT 500M MAXSIZE UNLIMITED

2. Monitor tablespace usage

Use monitoring query:

SELECT
tablespace_name,
ROUND(used_percent,2)
FROM dba_tablespace_usage_metrics;

3. Create alert threshold

Example:

Alert if usage > 85%

4. Separate tablespace types

Good design:

DATA_TS
INDEX_TS
TEMP_TS
UNDO_TS

5. Plan capacity

Monitor growth trend.


Quick ORA-01653 Troubleshooting Checklist

Step 1

Check tablespace usage

dba_tablespace_usage_metrics

Step 2

Check datafiles

dba_data_files

Step 3

Check free space

dba_free_space

Step 4

Add datafile / resize / enable autoextend


Saturday, January 3, 2026

Fix MS SQL Server SSL Error on Linux (PHP + ODBC Driver 17)



🚨 Fix MS SQL Server SSL Error on Linux (PHP + ODBC Driver 17)

Error:

[Microsoft][ODBC Driver 17 for SQL Server]
SSL Provider: error:1425F102:SSL routines:
ssl_choose_client_version:unsupported protocol

Environment:

  • PHP on Linux (CentOS / RHEL / Rocky / Alma / Oracle Linux)

  • Microsoft ODBC Driver 17 for SQL Server

  • OpenSSL 1.1+

  • SQL Server (older TLS configuration)


❌ The Problem (Why This Happens)

When PHP tries to connect to Microsoft SQL Server using ODBC Driver 17, the connection fails during SSL handshake.

Root Cause:

Modern Linux systems enforce strong TLS security by default:

  • Minimum TLS: TLS 1.2

  • Security Level: SECLEVEL=2

But many SQL Servers (especially older or misconfigured ones):

  • Only support TLS 1.0 / 1.1

  • Use weaker cipher suites

As a result, OpenSSL rejects the connection before authentication even starts.


🔍 Common Symptoms

  • Works on Windows, fails on Linux

  • PHP sqlsrv_connect() fails

  • Error code:

    SQLSTATE 08001
    Client unable to establish connection
    

✅ The Solution (Fix OpenSSL Configuration)

We will lower the OpenSSL minimum TLS protocol and security level, allowing compatibility with SQL Server.

⚠️ Important:
This is a system-wide OpenSSL change. Use only if upgrading SQL Server is not possible.


🛠 Step-by-Step Fix

🔐 Step 1: Backup OpenSSL Configuration

sudo cp /etc/pki/tls/openssl.cnf /etc/pki/tls/openssl.cnf.backup

✏️ Step 2: Edit OpenSSL Config

sudo nano /etc/pki/tls/openssl.cnf

➕ Step 3: Add These Lines at the VERY TOP

openssl_conf = openssl_init

[openssl_init]
ssl_conf = ssl_sect

[ssl_sect]
system_default = system_default_sect

[system_default_sect]
MinProtocol = TLSv1.0
CipherString = DEFAULT@SECLEVEL=1

📌 Make sure this is added before any existing content


🔄 Step 4: Restart Services

Apache

sudo systemctl restart httpd

PHP-FPM

sudo systemctl restart php-fpm

(Optional)

sudo systemctl restart nginx

🧪 Test PHP SQL Server Connection

<?php
$serverName = "SERVER_IP";
$connectionOptions = array(
    "Database" => "DB_NAME",
    "Uid" => "USERNAME",
    "PWD" => "PASSWORD",
    "TrustServerCertificate" => true
);

$conn = sqlsrv_connect($serverName, $connectionOptions);

if ($conn) {
    echo "Connection successful!";
} else {
    print_r(sqlsrv_errors());
}
?>

✅ If configured correctly, connection will succeed immediately.


⚠️ Security Warning (Must Read)

Lowering TLS security:

  • Allows older protocols

  • Weakens system-wide SSL enforcement

✅ Recommended Long-Term Fix:

  • Upgrade SQL Server to support TLS 1.2

  • Use modern cipher suites

  • Restore OpenSSL security level later

To revert:

sudo mv /etc/pki/tls/openssl.cnf.backup /etc/pki/tls/openssl.cnf
sudo systemctl restart httpd php-fpm


Monday, December 22, 2025

IBM Invented the Future — Then Abandoned It

 

IBM Invented the Future — Then Abandoned It

How IBM created personal computing, enterprise software, and foundational research—yet slowly exited consumer technology leadership.

This was due to prioritizing short-term services revenue, licensing away key innovations, and retreating from platforms that defined mass adoption.

IBM's Unrivaled Legacy of Innovation

IBM is presented as a foundational pioneer in computing, responsible for numerous innovations that shaped the digital world. Their influence spans from early computing to modern advancements.

Early Computing

IBM electrified early computing with tabulating machines in the 1930s and introduced the first commercial computer, the IBM 701, in 1952. These foundational steps laid the groundwork for the digital age.

Mainframe Dominance

The IBM System/360, launched in 1964, established a standardized computing architecture that went on to dominate enterprise IT for decades. Its modular design and upward compatibility were revolutionary.

Key Innovations

IBM's contributions extended to various fields:

  • Programming Languages: Developed FORTRAN (1957) and played a crucial role in SQL.
  • Storage: Introduced the hard disk drive (1956) and the floppy disk, revolutionizing data storage.
  • Data Management: Pioneered the relational database concept in the 1970s, which is fundamental to modern data systems.
  • Everyday Technologies: Responsible for innovations like the magnetic stripe card, the Universal Product Code (UPC) barcode, Dynamic Random-Access Memory (DRAM), and the Automated Teller Machine (ATM).

Personal Computer Revolution

IBM launched the IBM Personal Computer (PC) in 1981, a move that democratized computing and initiated the PC revolution, forever changing the landscape of personal technology.

Continued Innovation

Even today, IBM continues to push boundaries in artificial intelligence (IBM Watson), cloud computing, and quantum computing, consistently securing a high volume of U.S. patents year after year.

The Retreat: Ceding Ground in Personal Computing and Consumer Tech

Despite its profound contributions, IBM gradually relinquished leadership in crucial sectors, particularly consumer-facing technology. This strategic shift marked a turning point in its trajectory.

IBM PC Strategic Misstep

  • Embraced an open architecture and outsourced key components.
  • Licensed DOS from Microsoft, allowing Microsoft to license it to other manufacturers.
  • This led to a proliferation of "IBM-compatible" clones, eroding IBM's market share significantly.
  • By outsourcing the operating system and processor, IBM ceded crucial control of the PC ecosystem.

Corporate Culture

A reluctance within IBM to "cannibalize" its highly profitable mainframe business with cheaper PC solutions contributed significantly to its PC decline, a classic innovator's dilemma.

Exit from PC Hardware

Ultimately, IBM sold its personal computer division to Lenovo in 2005, marking its complete withdrawal from the PC hardware market it helped create.

Missed Consumer Market

IBM's steadfast enterprise focus meant it largely missed the burgeoning consumer technology market, allowing companies like Apple, Microsoft, and Google to dominate these new frontiers.

Mass-Market Adoption

The company struggled to capitalize on new technologies like internet search platforms and consumer-facing AI, allowing other players to lead in mass adoption and market penetration.

An old IBM mainframe computer, showcasing its imposing size and complex circuitry, surrounded by technical staff.

The Enterprise Software Paradox: Continued Presence, Shifting Leadership

IBM's role in enterprise software presents a nuanced picture of continued presence amidst shifting leadership dynamics.

Historical Strength

The System/360, and its successors, provided unparalleled enterprise IT infrastructure, creating a robust ecosystem for businesses worldwide.

Strategic Shift

IBM strategically invested in and acquired numerous software companies, including Lotus, Tivoli, and Cognos, culminating in the significant acquisition of Red Hat in 2019, bolstering its hybrid cloud capabilities.

Current Status

Software now accounts for over 40% of IBM's annual revenue, making it a formidable force in hybrid cloud and enterprise AI (with platforms like watsonx and IBM Z). It became the industry's top middleware producer.

Challenges

  • Struggled to adapt to networked Unix machines and the internet in the late 1980s/1990s, diminishing mainframe exclusivity.
  • Shifted to services, but profitability was often low, impacting overall financial health.
  • Spun off its managed IT infrastructure business into Kyndryl in 2020 as enterprises increasingly moved to cloud-native solutions.
  • Experienced slower growth in core cloud software (hybrid cloud unit/Red Hat) compared to agile rivals like Amazon and Microsoft.

Criticisms

Organizational bureaucracy and insufficient investment in cloud infrastructure hindered IBM's agility and competitive edge. As a result, IBM's enterprise leadership is no longer unchallenged.

The "Why": Strategic Missteps, Short-Term Focus, and Organizational Inertia

The decline in IBM's leadership in certain sectors can be attributed to a complex interplay of strategic errors, short-term financial focus, and internal organizational challenges.

Prioritization of Short-Term Services Revenue

The shift to a services-led model, while preventing financial losses, may have "compromised IBM's concentration on the technological innovation that established its reputation." Services offer consistent revenue but potentially lower margins and divert focus from long-term, disruptive research and development.

Licensing Away Key Innovations

The MS-DOS licensing for the IBM PC empowered competitors and inadvertently created the very market that eventually marginalized IBM. Later attempts to regain control with proprietary architectures (MCA, OS/2) were largely rejected by an industry that had embraced open standards.

Retreat from Mass Adoption Platforms

An enterprise-first mindset led to the overlooking of the burgeoning consumer market, the internet search boom, and a slow adaptation to cloud infrastructure, allowing new giants to dominate these critical paradigms. Poor management decisions, such as underestimating Microsoft's intentions during the OS/2 collaboration, exacerbated these issues.

Organizational Inertia and Bureaucracy

IBM's immense size and established processes hindered its rapid response to technological changes. An internal reluctance to embrace cheaper PC solutions that might "cannibalize" profitable mainframe revenue represented a classic innovator's dilemma, ultimately costing them market share.

A modern graphic representing cloud computing and interconnected data, symbolizing IBMs current focus on hybrid cloud and AI.

A Legacy Redefined

IBM's story is a compelling case study in technological leadership dynamics. It demonstrably "invented the future" multiple times but subsequently "abandoned" leadership in certain areas due to a combination of strategic outsourcing, a focus on short-term revenue, and significant organizational challenges.

Current Standing

Despite these shifts, IBM remains a formidable force in enterprise IT, particularly in hybrid cloud and artificial intelligence, continuing to shape the technological landscape.

Lesson

The profound lesson from IBM's journey is that inventing the future is distinct from maintaining leadership in it amidst relentless innovation and constant market shifts. Constant adaptation is key.

Conclusion

IBM's legacy is one of unparalleled innovation, serving as a stark illustration of how even technological pioneers can struggle to maintain control over the very futures they helped create. Its ongoing evolution continues to offer valuable insights into the dynamics of the tech industry.