Pages

Subscribe:

Ads 468x60px

Thursday, 30 July 2020

What is Oracle Database?


Oracle Database


Oracle Database  is one product among others forming the Oracle  suite (Oracle Database, Oracle Application Server, Oracle Developer Suite, Oracle Enterprise Manager Grid Control…).

Oracle Database  is the Oracle database management system that allows multiple users to access data simultaneously while ensuring availability and disaster recovery mechanisms.

Be aware that Oracle Database refers to the entire Oracle software, while database has a specific meaning in the Oracle architecture.

To guarantee a high level of performance, Oracle maintains the database thanks to memory structures (in random access memory: RAM) and physical structures (on hard disk) and uses processes for the storage of data in memory or on disk .

Writing to disk is only performed when necessary and under conditions while Memory is used as much as possible since memory access is faster than disk access (performance gain).


In the event of a power outage, for example, Oracle will be able to recover well if data in memory, at the time of the incident, is not written to disk. This is the recovery of the instance managed by the SMON process discussed later in the oracle architecture.

An instance failure requires recovery, while a physical failure (such as a disk crash) requires a restore followed by a recovery.

Restoration and recovery are two different terms that should be clearly distinguished. The restoration is made from backup files and the recovery allows to reapply to the restored data files, the modifications already made on the base to find the consistent state of the database before the incident.


In the example in the figure, recovery at time t2 requires restoring the last available S1 backup and reimplementing any changes that occurred in the interval t1-t2.

To learn more about the components and basic concepts of the Oracle architecture, take look at our Expert DBA Team Club blog and more advance topics are available at this source.


What is Cursors in Oracle?

What is the Cursors?


A cursor is a pointer to a private SQL memory area allocated (in PGA memory) for processing an SQL statement. The cursor is used to process one by one the records (rows of tables) returned by the SQL statement in question.

Two types of cursors can be distinguished:

    Implicit Cursor: When a user issues an SQL command, Oracle generates a cursor for processing that command. This cursor created and managed by Oracle is called an implicit cursor.
    Explicit cursor: if you want to manage an SQL command within your PL / SQL code, you can explicitly create a cursor to process the rows returned by the command one by one.

Here is an example :

DECLARED
name emp.ename% TYPE;
salary emp.sal% TYPE;

CURSOR C1 IS SELECT ename, NVL (sal, 0) FROM emp;

BEGIN
OPEN C1;

LOOP
FETCH C1 INTO name, salary;
EXIT WHEN C1% NOTFOUND;
DBMS_OUTPUT.PUT_LINE (name || 'earns' || salary || 'dollars');
END LOOP;

CLOSE C1;
END;

Explanations:

CURSOR C1: used to declare a cursor with the name C1
name emp.ename% TYPE means that the variable name is of the same type as the ename column of the emp table (Another predefined type% ROWTYPE can be used to declare a record variable of the same type as the record of a table)
Open C1: open the cursor
Fetch: fetch the current record and load it into the name and salary variables and then advance the pointer to the next record
C1% NOTFOUND: returns TRUE if the cursor points beyond the last record. Other attributes of the cursor can be used:

    % FOUND,
    % ROWCOUNT which returns the number of rows returned by the SQL order of the cursor,
    % ISOPEN which returns true if the cursor is open.

Close C1: used to close the cursor and free the resources.

For advance topics of Oracle DBA tutorials and tips. Stay connected with our following blogs. Dba tips and Dbametrix.

Transaction in Oracle Database

The transactions


Managing transactions is at the heart of database processing. To allow multiple users to access it simultaneously, the DBMS must manage transactions with the minimum of conflicts while ensuring the consistency of the database.

A transaction is a logical unit made up of one or more SQL statements.

DML command 1
DML command 2
................................
................................
................................
DML command n

A transaction begins implicitly with the execution of the first SQL command and ends with a COMMIT to commit or a ROLLBACK to roll back the transaction.

The transaction continues executing SQL commands one at a time until one of the following occurs:

    COMMIT: Transaction encounters an explicit COMMIT statement, all changes made to the database up to this point are committed.

    ROLLBACK: Transaction encounters an explicit ROLLBACK statement, all changes made to the database up to this point are rolled back.

  DML instruction: If an DDL instruction is encountered such as CREATE, DROP, RENAME, or ALTER, Oracle first commits the current DML instructions for the transaction and then executes and commits the DDL instruction in question. This is an implied commit.

    Normal end of the calling program: if the program ends without errors, the transaction is committed implicitly. This is the case when you use the sqlplus tool, then you enter a series of DML commands in interactive mode, then you exit the session normally via the sqlplus "EXIT" command. In this case an implicit commit is applied to your transaction.

    Abnormal program termination: Such as a network cut or a program kill, the transaction is implicitly rolled back.


Learning Oracle DBA is not too short and quick guide. You should need to read several books and Oracle documentation for understanding of depth of each topics. You can get more tips and tutorials for Oracle database administration from our other resources like this or this.