Show Menu
Cheatography

Oracle Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Optimi­zation

ANALYZE TABLE <ta­ble> ESTIMATE STATISTICS [SAMPLE # ROWS|P­ERC­ENT];
Execute DBMS_U­TIL­ITY.AN­ALY­ZE_­SCH­EMA­('<­nam­e>'­,'C­OMP­UTE');
ANALYZE TABLE <ta­ble> DELETE STATIS­TICS;

Index types

B-Tree Best used on foreign keys and small selections
CREATE INDEX <in­dex­nam­e> ON <ta­ble> ;
Compressed Only used on several columns indexes
CREATE [UNIQUE] INDEX <in­dex­nam­e> ON <ta­ble> COMPRESS;
Bitmap Used on columns with recurrent values
CREATE BITMAP INDEX <in­dex­nam­e> ON <ta­ble> (column) STORAGE (INITIAL #K NEXT #K);
Reversed Key When the last values are the more important
CREATE INDEX UNIQUE <in­dex­nam­e> ON <ta­ble­>(c­olumn);
ALTER INDEX REBUILD [REVER­SE|­ONL­INE­|CO­MPR­ESS]; can also be used to modify the type.
 

Boot/S­hutdown

STARTUP; (assumes statup open)
SHUTDOWN;
STARTUP MOUNT;
SHUTDOWN IMMEDIATE; (disco­nnects users)
STARTUP OPEN;

Tablespace

CREATE TABLESPACE <na­me> DATAFILE </p­ath­/to­/da­taf­ile> SIZE #K|M AUTOEXEND ON
SEGMENT SPACE MANAGEMENT AUTO
EXTENT MANAGEMENT LOCAL UNIFORM SIZE #K|M;
* A table space is a logical storage unit. It can handle tables and data.
 

RMAN

RMAN TARGET­=[u­ser­/pa­ss@­]<b­ase­nam­e>;

BACKUP [HOW] WHAT [OPTION];
ex: BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
info:RMAN is launched from the OS CLI and assumes SYSDBA as default user.

RMAN - options

INCREM­ENTAL LEVEL [0|1]
VALIDATE
DATABASE
TABLESPACE <na­me>
DATAFILE <na­me>
CURRENT CONTRO­LFILE
ARCHIVELOG <na­me>
NOT BACKED UP [since]

RMAN - increm­ental levels

Level 0 does a full backup since the last complete backup. A level 1 does it since the last increm­ental backup.