Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Explain how to create a new database

Creating database is very simple in Oracle. We can use the DBCA database configuration assistant to create a
database. We can launch the DBCA by using the windows command prompt utility by just typing dbca. As the
welcome window appears it provides five options out of which one is creating database. This is fairly straightforward
we can create a new database from scratch, using a create database command or doing an RMAN restore of a
template database with many options.

    CREATE DATABASE database_names USER SYSTEM IDENTIFIED BY password;

Explain how to rename a database

To completely re-name a database you need to change all of the components where the instance name is located:
External files: sqlnet.ora, tnsnames.ora, init.ora (spfile)
Internal locations: Data dictionary.
Follow the steps to rename the database as described:

 On the old system sign on as SYSDBA into SQLPLUS and issue: “alter database backup controlfile to
trace”;
 Shutdown the old database.
 Change all references to the old instance name in all locations for sqlnet.ora, protocol.ora, tnsnames.ora
and the init.ora
 Change the database name in the file to reference the new ORACLE_SID instance name.

Explain how to resize tablespaces and data files

Oracle provides different types of tablespace namely SYSTEM tablespaces, the SYSAUX tablespace, temporary
tablespaces, undo tablespaces, and bigfile tablespaces.

The procedures and methods available for resizing a tablespace are slightly different, depending on whether the
tablespace is a smallfile or a bigfile tablespace.

Smallfile case I:
For example we need to alter the size of the table space named users which contain one database file starting out of
5 MB. First we will make it to 15 MB and then reduce its size to 10 MB.

SQL> alter database datafile '/u01/app/oracle/oradata/rmanrep/users01.dbf' resize 15m;


SQL > alter database datafile '/u01/app/oracle/oradata/rmanrep/users01.dbf' resize 10m;

Bigfile Case II:


A bigfile tablespace consists of one and only one datafile. Remember: Operations that are valid only at the datafile
level with smallfile tablespaces can be used with bigfile tablespaces at the tablespace level
SQL> alter tablespace bigfile_name resize 1g;

Explain how to find the overall database size

An oracle database consists of data files; redo log files, control files, temporary files. And in order to find out the size
of the entire database we need to sum up size of all these files.

The biggest portion of a database's size comes from the data files. To find out how many megabytes are allocated to
ALL data files: select sum (bytes)/1024/1024 "Meg" from dba_data_files;

To get the size of all TEMP files: select nvl (sum (bytes), 0)/1024/1024 "Meg" from dba_temp_files;
To get the size of the on-line redo-logs: select sum (bytes)/1024/1024 "Meg" from sys.v_$log; Hence to find the full
size of database sum up all these files size.

Explain how to find used/free space in a TEMPORARY tablespace

You can easily compute the amount of free space in each tablespace by using the following query:
SQL> select tablespace_name, sum (bytes) from dba_free_space group by tablespace_name;
Remember: The free space does not take into account the space that would be available if and when the datafiles in
a tablespace are auto extended. Also, any space allocated to a table for rows that are later deleted will be available
for future inserts into the table, but it is not counted in the preceding query results as space available for other
database objects

Why and when should I backup my database?

Backup is generally needed for safety reason. For example if something may go wrong in the live database which is
running. Then immediately we can restore the backup and server the purpose. We can take back up as per our wish. 
For example if the database is having much of the insert, update and delete query executing daily in large numbers
then we need to take the backup every 5 to 6 days. Rest depends upon the DBA who is managing the database. Or

How often you choose to perform these backup routines is really dependent on the data requirements of your
company. If you do not know what those are then you need to find out either by referring to them or asking for them to
be created through a research and investigation process.

What strategies are available for backing-up an Oracle database?

The backup strategies that are provided by Oracle are as follows:

 Logical backup using Exports and import.


 Physical file system backup
 RMAN Recovery Manger which is also known as incremental files system backup.

Difference between online and offline backups.

 Online backup is one which is taken at the time the database is running in the ARCHIVELOG mode.
 Following files should be backed up during the Offline Backup: All data file, all control file and all online redo
log file. But in the case of the online backup following files is backed up: All data files all archived redo log
files and one control file via the alter database command.
 Offline database we cannot rely upon but in case of online database no issues.
 Offline backup no archived mode is required but in the online backup it is must.

Difference between restoring and recovering

Restoring a database is copying the physical files from a backup medium (disk or tape) to the appropriate file
locations for database operation Recovery is process of updating database files restored from backup w/changes
made to the database since backup, typically using redo log files.

Recovering files typically refers to saving one or more files, while a restore usually refers replacing a complete
system or hard drive from a full system backup.

Restore means restoring a database backup from a backup medium. Recovery" means recovering redolog
information.
Explain how to backup a database using the export utility

The logical backup in Oracle database is done by Export utility. Oracle’s Export utility queries the database, including
the data dictionary, and writes the output to a binary file called an export dump file. The backup through export utility
can be done in four phase. These phases are commonly known as BACKUP modes. The modes are: Full mode,
Tablespace mode, User mode, and Table mode.

In Full mode, the full database is exported. The entire data dictionary is read, and the DDL needed to re-create the
full database is written to the export dump file. This file includes creation commands for all tablespaces, all users, and
all of the objects, data, and privileges in their schemas.

In Tablespace mode, all of the objects contained in the specified tablespace(s) will be exported, including the
definition of indexes on the contained objects, even if they are in another tablespace.

In User mode, a user’s objects are exported, as well as the data within them. All grants and indexes created by the
user on the user’s objects are also exported. Grants and indexes created by users other than the owner are not
exported.

In Table mode, a specified table is exported. The table’s structure, indexes, and grants are exported along with or
without its data. Table mode can also export the full set of tables owned by a user.

Explain how to put a database into ARCHIVELOG mode

To make use of the ARCHIVELOG capability, the database must first be placed in ARCHIVELOG mode. The
following listing shows the steps needed to place a database in ARCHIVELOG mode.

Run SQLPLUS and mount the database.


Then alter it as shown here:

SQL> connect system/manager as sysdba


SQL> startup mount mydb;
SQL> alter database archivelog;
SQL> alter database open;

Here mydb is database name.


Further if we want to see the current archive log execute the following command from SQLPLUS.
Archive log list;
The following command will display the current ARCHIVELOG status of the database from within SQLPLUS.

Explain how to do off-line database backups

Consistent offline backups occur when the database has been shut down normally using the normal, immediate, or
transactional option of the shutdown command.

Process: While the database is shut down, each of the files actively used by the database is backed up. These files
provide a complete image of the database as it existed at the moment it was shut down. Doing offline backup is easy
the only point that must be kept in mind is:

 If we are using raw devices for database storage, with or without ASM, you’ll have to backup these devices
as well using operating system commands such as dd in combination with a compression utility, as dd
if=/dev/sdb | gzip > /mnt/bkup/dw_sdb_backup.img.gz
 We should not rely on an offline backup performed following a shutdown abort, because it may be
inconsistent.
Explain how to do on-line database backups

Online backup can be done while the database is open. The only condition needs to be satisfied is it must be in
ARCHIVED mode. Implementing Online Backups:

 Set the database into backup state by using the alter tablespace . . . begin backup command for each
tablespace or alter database begin backup to put all tablespaces into online backup mode.
 Back up the data files using operating system commands.
 Set the database back to its normal state by issuing alter tablespace . . . end backup for each tablespace or
alter database end backup for all tablespaces in the database.
 Archive the unarchived redo logs so that the redo required to recover the tablespace backup is used by
issuing the command alter system archive log current.
 Back up the archived redo log files. If necessary, compress or delete the backed-up archived redo log files
to free space on disk.
 Back up the control file.

What is RMAN and how does one use it?

RMAN in Oracle stands for Oracle Recovery Manager. RMAN takes backup and recovery to a new level of protection
and ease of use. We can use RMAN with command line mode and with OEM web interface. It serves as an optional
catalog for database recovery in Oracle. In order to use RMAN one has to create RMAN account.

Creating RMAN account:

SQL> create tablespace rman datafile '+data1' 2 size 125m auto extend on next 50m maxsize 500m;
We will get am message that tablespace created.

SQL> grant recovery_catalog_owner to rman identified by rman;


Grant succeeded.

SQL> alter user rman default tablespace rman 2 quota unlimited on rman;
User altered.

Now the RMAN account has been created and we can log on and use it.

Explain how to backup and restore a database using RMAN

RMAN provides two modes of full database backup. Full database backup can be done as:

RMAN> backup as backupset database spfile;


The query will execute till the auto backup is completed. After it is completed you will get a message on the screen
as: Finished controlled file and spfile backup. After viewing this command next execute:

RMAN> sql ‘alter system archive log current’;


The alter system command ensures that we have archived logs for all transactions, including those that occurred
while the backup was taking place; this ensures that we can perform media recovery after restoring this backup.

After that we can connect as sysdba and can view the parameters of recovery.

RMAN provide various options for the recovery of the database. Among the few are block media recovery, restoring a
control file, restoring a table space etc.
RMAN> recover tablespace users;

Explain how to backup and restore archived log files

We can archive logs using RMAN. RMAN provides option that once the backup is completed, we have the option to
leave the logs in place, to delete only the logs that RMAN used for the backup, or to delete all copies of the archived
logs that were backed up to tape.

The backup and restore can be done as:


RMAN> backup device type sbt archivelog all delete input;
In the case when we want to delete all the input files then we use delete all input option instead of all delete input.

Explain how to create a RMAN recovery catalog

Creating RMAN account:


SQL> create tablespace rman datafile '+data1' 2 size 125m auto extend on next 50m maxsize 500m;
We will get am message that tablespace created.
SQL> grant recovery_catalog_owner to rman identified by rman;
Grant succeeded.
SQL> alter user rman default tablespace rman 2 quota unlimited on rman;
User altered.
Now the RMAN recovery catalog has been created and we can log on and use it.

Explain how to integrate RMAN with third-party Media Managers

Recovery Manager is the single tool for guaranteed, efficient, manageable Oracle database backup and recovery.
RMAN integrates with leading 3rd party backup vendors for backup to tape, via the System Backup to Tape API.
These backup vendors have implemented interfaces to their products using the API, allowing RMAN to drive backups
to and restores from tape.

To store backups on tape, RMAN requires media manager software, a third party software program that writes,
reads, and manages sequential media such as tapes to backup and recovery data. The core of the RMAN and media
manager software integration is the media management library, supplied by the backup vendor. This library contains
an implementation of the SBT API functions, and is linked in with the Oracle server binary. Oracle calls these SBT
functions to back up and restore data files to and from media controlled by the media manager. When performing
backups or restores, the RMAN client connects to the target instance and directs the instance to talk to the media
manager. No direct communication occurs between the RMAN client and the media manager; all communication
occurs on the target instance.

Explain how to clone/duplicate a database with RMAN

In order to clone/duplicate a database with RMAN follows the steps below:

 Create an Oracle password file for the Auxiliary instance


 Create new init.ora for the database.
 Configure SQL NET for the new database.
 Create the required directories as defined in init.ora.
 Startup nomount the Auxiliary instance on the target node.
 Check that source database is mounted or open.
 Check a backup of all the datafiles and archived logs exist in target server.
 Start RMAN and allocate Auxiliary channels to new database.
 Execute the duplicate database command.
 Check the new database.

You might also like