Oracle DBA Issues and Solutions - Common Problems & Fixes
Oracle DBA Issues and Solutions
Section titled “Oracle DBA Issues and Solutions”A quick reference guide to the most common Oracle database problems and their solutions. Each issue includes diagnostic queries and step-by-step fixes.
Performance Issues
Section titled “Performance Issues”Database Running Slow
Section titled “Database Running Slow”Quick Diagnosis:
-- Check top wait eventsSELECT event, total_waits, time_waited_micro/1000000 as secondsFROM v$system_eventWHERE wait_class != 'Idle'ORDER BY time_waited_micro DESCFETCH FIRST 10 ROWS ONLY;
-- Find resource-intensive sessionsSELECT sid, serial#, username, sql_id, event, seconds_in_waitFROM v$sessionWHERE status = 'ACTIVE' AND type = 'USER'ORDER BY seconds_in_wait DESC;Solutions:
- Generate AWR Report for detailed analysis
- Check for blocking locks
- Review execution plans
High CPU Usage
Section titled “High CPU Usage”-- Sessions consuming most CPUSELECT s.sid, s.serial#, s.username, s.program, st.value/100 as cpu_secondsFROM v$session sJOIN v$sesstat st ON s.sid = st.sidJOIN v$statname sn ON st.statistic# = sn.statistic#WHERE sn.name = 'CPU used by this session'ORDER BY st.value DESCFETCH FIRST 10 ROWS ONLY;Related: CPU Analysis Scripts
Space Issues
Section titled “Space Issues”Tablespace Full
Section titled “Tablespace Full”Quick Check:
SELECT tablespace_name, ROUND(used_percent, 2) as pct_used, ROUND((tablespace_size - used_space) * 8192/1024/1024, 2) as free_mbFROM dba_tablespace_usage_metricsWHERE used_percent > 85ORDER BY used_percent DESC;Solutions:
- Add datafile:
ALTER TABLESPACE ts ADD DATAFILE '/path/file.dbf' SIZE 10G; - Enable autoextend:
ALTER DATABASE DATAFILE '/path/file.dbf' AUTOEXTEND ON; - Identify large segments: dsegbig.sql
Related: Space Analysis Scripts
TEMP Tablespace Full
Section titled “TEMP Tablespace Full”-- Check TEMP usageSELECT tablespace_name, used_blocks, free_blocksFROM v$temp_space_header;
-- Find sessions using TEMPSELECT s.sid, s.serial#, s.username, u.blocks * 8/1024 as temp_mbFROM v$session sJOIN v$tempseg_usage u ON s.saddr = u.session_addrORDER BY u.blocks DESC;Related: ORA-01652
Connection Issues
Section titled “Connection Issues”Cannot Connect to Database
Section titled “Cannot Connect to Database”| Error | Quick Fix |
|---|---|
| ORA-12154 | Check tnsnames.ora syntax |
| ORA-12541 | Start the listener: lsnrctl start |
| ORA-01034 | Start the database: startup |
| ORA-28000 | Unlock account: ALTER USER x ACCOUNT UNLOCK; |
Too Many Connections
Section titled “Too Many Connections”-- Check current vs max sessionsSELECT (SELECT value FROM v$parameter WHERE name = 'sessions') as max_sessions, (SELECT COUNT(*) FROM v$session) as current_sessions;
-- Sessions by programSELECT program, COUNT(*) as countFROM v$sessionGROUP BY programORDER BY COUNT(*) DESC;Related: ORA-00018 | ORA-00020
Lock and Blocking Issues
Section titled “Lock and Blocking Issues”Find Blocking Sessions
Section titled “Find Blocking Sessions”SELECT blocker.sid as blocker_sid, blocker.username as blocker_user, waiting.sid as waiting_sid, waiting.username as waiting_user, waiting.eventFROM v$session waitingJOIN v$session blocker ON waiting.blocking_session = blocker.sidWHERE waiting.blocking_session IS NOT NULL;Kill Blocking Session:
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;Related: gvlockb.sql | ORA-00060
Backup & Recovery Issues
Section titled “Backup & Recovery Issues”Check Backup Status
Section titled “Check Backup Status”SELECT input_type, status, start_time, end_timeFROM v$rman_backup_job_detailsWHERE start_time > SYSDATE - 7ORDER BY start_time DESC;Flash Recovery Area Full
Section titled “Flash Recovery Area Full”-- Check FRA usageSELECT * FROM v$flash_recovery_area_usage;
-- Delete obsolete backupsRMAN> DELETE OBSOLETE;Related: ORA-19815 | FRA Scripts
Invalid Objects
Section titled “Invalid Objects”Fix Invalid Objects
Section titled “Fix Invalid Objects”-- Count invalid objectsSELECT object_type, COUNT(*)FROM dba_objectsWHERE status = 'INVALID'GROUP BY object_type;
-- Recompile allEXEC UTL_RECOMP.RECOMP_PARALLEL(4);
-- Recompile specific schemaEXEC UTL_RECOMP.RECOMP_SERIAL('SCHEMA_NAME');Related: dinvalid.sql
Common Error Quick Reference
Section titled “Common Error Quick Reference”| Error | Issue | Quick Fix |
|---|---|---|
| ORA-00001 | Duplicate key | Check unique constraints |
| ORA-00904 | Invalid column | Check column names |
| ORA-00942 | Table not found | Check schema/grants |
| ORA-01000 | Too many cursors | Increase OPEN_CURSORS |
| ORA-01403 | No data found | Add exception handling |
| ORA-01555 | Snapshot too old | Increase UNDO retention |
| ORA-04031 | Shared pool issue | Flush or resize SGA |
Monitoring Checklist
Section titled “Monitoring Checklist”Daily checks for Oracle DBAs:
- Alert Log - Check for errors
- Tablespace Space - Verify free space > 15%
- Backup Status - Confirm successful completion
- Performance - Review wait events
- Invalid Objects - Recompile if needed
Scripts: Health Check Suite