Interview Notes Tutorials
Home
Career Center
Interview Notes
Career Center
Interview NotesOracle Interview Preparation Notes Part 11
Oracle Database Backup
Backup Considerations:
Archive when…
1. No data loss is acceptable.
2. Database is needed online 24 by 7.
3. Point in time recovery may be needed (roll db forward back to a prior state).
When structural changes are made…
1. Archiving è After changes, ALTER DATABASE BACKUP CONTROLFILE TO ‘file’;
2. No Archive è Backup entire database before and after the change is made.
· Read Only tablespaces only need backed up after they are set to read only or are manually changed.
Physical backups:
Types: Closed = database level, OPEN = tablespace or datafile level.
Get file information from…
V$Tablespace and V$datafile (or DBA_DATA_FILES).
V$Controlfile, V$Logfile
COLD BACKUPS:
1. Shutdown NORMAL or IMMEDIATE or TRANSACTIONAL (abort is inconsistent).
2. All datafiles, controlfiles, online redo logs (optional) and the init.ora parameter file.
3. Open the database
HOT BACKUPS:
1. ALTER TABLESPACE ts1 BEGIN BACKUP
2. Back up the tablespace datafiles.
3. ALTER TABLESPACE ts1 END BACKUP …
4. Force a log switch – ALTER SYSTEM SWITCH LOGFILE;
5. Backup controlfile – ALTER DATABASE BACKUP CONTROLFILE TO ‘file’ REUSE;
Logical Backups:
Can be accomplished through exports.
EXPORT / IMPORT (LOGICAL):
Export – makes a logical copy of object definitions and data to a binary file (Logical backup).
Conventional (DIRECT=N) uses SQL select to extract data into buffer cache, then into evaluation buffer
Direct Path (DIRECT=Y) Data is read from disk into buffer cache – data in blocks is not reorganized.
COMPRESS=Y – initial extent resized as total current segment size
FEEDBACK=x – A dot is displayed in log file for every x records inserted.
FULL=Y or OWNER=user or TABLES=schema.table
CONSISTENT=Y – entire export as 1 read only transaction.
RECORD=Y – update the information in the SYS tables (INCxxx).
* INCTYPE=
COMPLETE – Export all objects and data, reinitialize dictionary views.
INCREMENTAL – All tables that have changed since last incremental, complete, or cumulative.
CUMULATIVE – All tables that have changed since last complete or cumulative.
Dictionary Tables:
SYS.INCFIL – Tracks all exports in current cycle.
SYS.INCEXP – Tracks which objects are in which export files.
SYS.INCVID – Tracks the last export information.
· Clusters are not exported with the Table mode, they are in User or Full mode.
· SYS owner objects (data dictionary) are never exported.
Import – Reads export files and copies object definitions and data into an Oracle database.
IGNORE=Y – Overlook object creation errors – causes rows to be imported into existing tables.
INDEXFILE=file – Index creation commands written to file (no actual import).
Order of operations: Type defs | Data | B-Tree indexes | Views, procedures, constraints | bitmap indexes.
Before import: Disable Ref Integrity before imports and increase buffer size for better performance
After import: Compile all invalid objects, reenable RI.
STANDBY DATABASES:
· Use standby databases to minimize recovery time.
· Archives from the primary database are applied to the standby.
· Adding datafiles will propagate to standby (logged activity).
· Renaming datafiles will not propagate to the standby and must be done manually.
· Unrecoverable operations will not propagate to the standby.
To create a standby database…
1. ALTER DATABASE CREATE STANDBY CONTROLFILE AS ‘file’;
2. ALTER SYSTEM ARCHIVE LOG CURRENT; archive the current redo logs.
3. Copy the controlfile, archive logs, and backed up datafiles to standby location.
4. Start the standby in NOMOUNT mode.
5. ALTER DATABASE MOUNT EXCLUSIVE STANDBY DATABASE;
To keep standby current…
1. Copy the archive logs as they are created to the Standby location.
2. RECOVER FROM ‘archive location’ STANDBY DATABASE;
To activate the standby database:
1. ALTER DATABASE ACTIVATE STANDBY DATABASE – on the current primary.
2. SHUTDOWN the current primary database. Startup the standby database (resetlogs).
Read Next: Oracle Interview Preparation Notes Part 12
Related Topics
