0% found this document useful (0 votes)
2 views5 pages

Oracle DBA Commands Formulas Guide

The document provides a comprehensive guide on Oracle DBA commands and formulas, covering essential tasks such as database startup and shutdown, user and privilege management, tablespace and datafile management, backup and recovery commands, performance monitoring, and advanced DBA commands. It includes SQL queries for checking the Oracle version, current user, and database status, as well as commands for managing listeners and network settings. Additionally, it outlines Linux commands relevant to Oracle DBAs for process monitoring and disk space checks.

Uploaded by

fausacademy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Oracle DBA Commands Formulas Guide

The document provides a comprehensive guide on Oracle DBA commands and formulas, covering essential tasks such as database startup and shutdown, user and privilege management, tablespace and datafile management, backup and recovery commands, performance monitoring, and advanced DBA commands. It includes SQL queries for checking the Oracle version, current user, and database status, as well as commands for managing listeners and network settings. Additionally, it outlines Linux commands relevant to Oracle DBAs for process monitoring and disk space checks.

Uploaded by

fausacademy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Oracle DBA Commands & Formulas Guide

Basic Oracle Environment Commands

Check Oracle version


SELECT * FROM v$version;

Show current user


SELECT user FROM dual;

Show current date/time


SELECT sysdate FROM dual;

Show Oracle SID (Linux)


echo $ORACLE_SID

Show ORACLE_HOME path


echo $ORACLE_HOME

Database Startup and Shutdown

Startup database
STARTUP;

Startup with mount mode (for recovery)


STARTUP MOUNT;

Shutdown immediate
SHUTDOWN IMMEDIATE;

Shutdown abort (last resort)


SHUTDOWN ABORT;

Shutdown transactional
SHUTDOWN TRANSACTIONAL;

User and Privilege Management

Create user
CREATE USER username IDENTIFIED BY password;
Grant role or privilege
GRANT CONNECT, RESOURCE TO username;

Revoke privilege
REVOKE CONNECT FROM username;

Drop user with cascade


DROP USER username CASCADE;

Tablespace and Datafile Management

Create tablespace
CREATE TABLESPACE ts_name DATAFILE '/path/filename.dbf' SIZE 100M AUTOEXTEND ON;

Add datafile to tablespace


ALTER TABLESPACE ts_name ADD DATAFILE '/path/filename2.dbf' SIZE 50M AUTOEXTEND ON;

Check tablespace size


SELECT tablespace_name, file_name, bytes/1024/1024 AS size_mb FROM dba_data_files;

Check free space in tablespace


SELECT tablespace_name, SUM(bytes)/1024/1024 AS free_space_mb FROM dba_free_space GROUP BY

tablespace_name;

Backup and Recovery Commands

Check if DB is in archivelog mode


ARCHIVE LOG LIST;

Enable archivelog mode


SHUTDOWN IMMEDIATE;

STARTUP MOUNT;

ALTER DATABASE ARCHIVELOG;

ALTER DATABASE OPEN;

Cold backup steps


1. Shutdown database

2. Copy datafiles, control files, redo logs manually

Hot backup commands


ALTER TABLESPACE tablespace_name BEGIN BACKUP;
-- Copy datafiles

ALTER TABLESPACE tablespace_name END BACKUP;

RMAN (Recovery Manager) Commands

Connect to RMAN target


rman target /

Full database backup


BACKUP DATABASE PLUS ARCHIVELOG;

Backup incremental level 1


BACKUP INCREMENTAL LEVEL 1 DATABASE;

Restore database
RESTORE DATABASE;

RECOVER DATABASE;

Delete obsolete backups


DELETE OBSOLETE;

Performance Monitoring Commands

Show current sessions


SELECT sid, serial#, username, status FROM v$session;

Show locks
SELECT * FROM v$lock;

Top 5 SQL by CPU


SELECT * FROM (SELECT sql_id, cpu_time FROM v$sql ORDER BY cpu_time DESC) WHERE ROWNUM

<= 5;

Generate AWR report


@?/rdbms/admin/awrrpt.sql

Data Dictionary Views

List tables
SELECT table_name FROM user_tables;
List users
SELECT username FROM dba_users;

List tablespaces
SELECT tablespace_name FROM dba_tablespaces;

Show datafiles
SELECT file_name FROM dba_data_files;

Advanced DBA Commands

Switch logfile
ALTER SYSTEM SWITCH LOGFILE;

Shrink table space


ALTER TABLE table_name SHRINK SPACE;

Flush shared pool


ALTER SYSTEM FLUSH SHARED_POOL;

Flush buffer cache


ALTER SYSTEM FLUSH BUFFER_CACHE;

Monitor redo log switches


SELECT * FROM v$log_history ORDER BY first_time DESC;

Listener & Network Commands

Start listener
lsnrctl start

Stop listener
lsnrctl stop

Listener status
lsnrctl status

Reload listener config


lsnrctl reload

Linux Commands for Oracle DBA


Check Oracle processes
ps -ef | grep ora_

Check disk space


df -h

Tail alert log


tail -f $ORACLE_BASE/diag/rdbms/<db_name>/<db_sid>/trace/alert_<db_sid>.log

Check open ports


netstat -tnlp | grep 1521

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy