You are on page 1of 10

CHAPTER ONE

ORACLE Overview

Oracle database (Oracle DB) is a relational database management


system (RDBMS) from the Oracle Corporation. Originally
developed in 1977 by Lawrence Ellison and other developers,
Oracle DB is one of the most trusted and widely-used relational
database engines.
The system is built around a relational database framework in
which data objects may be directly accessed by users (or an
application front end) through structured query language (SQL).
Oracle is fully scalable relational database architecture and is
often used by global enterprises, which manage and process data
across wide and local area networks. The Oracle database has its
own network component to allow communications across
networks.
Oracle DB is also known as Oracle RDBMS and, sometimes, just
Oracle.
Oracle Corporation now de-emphasizes the SCOTT schema, as it
uses few features of more recent Oracle releases. Most
recent examples supplied by Oracle Corporation reference the
default HR or OE schemas.
Other default schemas include:

 SYS (essential core database structures and utilities)


 SYSTEM (additional core database structures and utilities,
and privileged account)
 OUTLN (used to store metadata for stored outlines for stable
query-optimizer execution plans.)
 BI , IX , HR , OE , PM , and SH (expanded sample
schemas containing more data and structures than the
older SCOTT schema).

1
Oracle's RDBMS release numbering has used the following:

 Oracle 2
 Oracle 3
 Oracle 4
 Oracle 5
 Oracle 6
 Oracle 7
 Oracle 8
 Oracle 8i
 Oracle 9i
 Oracle 10g
 Oracle 11g
 Oracle 12c

What is SQL?

SQL is Structured Query Language, which is a computer


language for storing, manipulating and retrieving data stored in
relational database.

SQL is the standard language for Relation Database System. All


relational database management systems like MySQL, MS
Access, Oracle, Sybase, Informix, postgres and SQL Server use
SQL as standard database language.

SQL is a language of database, it includes database creation,


deletion, fetching rows and modifying rows etc.

There are also different dialects of SQL, such as:

 MS SQL Server using T-SQL,


 Oracle using PL/SQL,
 MS Access version of SQL is called JET SQL (native format)
etc.

2
Why SQL?

 Allows users to access data in relational database


management systems.
 Allows users to describe the data.
 Allows users to define the data in database and manipulate
that data.
 Allows users to create and drop databases and tables.
 Allows users to create view, stored procedure, functions in a
database.
 Allows users to set permissions on tables, procedures and
views

History:

 1970 -- Dr. E. F. "Ted" of IBM is known as the father of


relational databases. He described a relational model for
databases.
 1974 -- Structured Query Language appeared.
 1978 -- IBM worked to develop Codd's ideas and released a
product named System/R.
 1986 -- IBM developed the first prototype of relational
database and standardized by ANSI. The first relational
database was released by Relational Software and its later
becoming Oracle.

SQL Process:

When you are executing an SQL command for any RDBMS, the
system determines the best way to carry out your request and
SQL engine figures out how to interpret the task.

There are various components included in the process. These


components are Query Dispatcher, Optimization Engines, Classic
Query Engine and SQL Query Engine, etc. Classic query engine
handles all non-SQL queries, but SQL query engine won't handle
logical files.
3
Following is a simple diagram showing SQL Architecture:

SQL Commands:

The standard SQL commands to interact with relational


databases are CREATE, SELECT, INSERT, UPDATE, DELETE
and DROP. These commands can be classified into groups based
on their nature:

DDL - Data Definition Language:

Command Description

CREATE: Creates a new table, a view of a table, or other object in


database

ALTER: Modifies an existing database object, such as a table.

DROP: Deletes an entire table, a view of a table or other object in


the database.

DML - Data Manipulation Language:

Command Description
4
INSERT: Creates a record

UPDATE: Modifies records

DELETE: Deletes records

SELECT: Retrieves certain records from one or more tables

DCL - Data Control Language:

Command Description

GRANT: Gives a privilege to user

REVOKE: Takes back privileges granted from user

PL/SQL — Overview

PL/SQL is a combination of SQL along with the procedural


features of programming languages. It was developed by Oracle
Corporation in the early 90's to enhance the capabilities of SQL.

PL/SQL is one of three key programming languages embedded in


the Oracle Database, along with SQL itself and Java.

This tutorial will give you great understanding on PL/SQL to


proceed with Oracle database and other advanced RDBMS
concepts.

 PL/SQL is a completely portable, high-performance


transaction-processing language.
 PL/SQL provides a built-in, interpreted and OS independent
programming environment.
 PL/SQL can also directly be called from the command-line
SQL*Plus interface.
 Direct call can also be made from external programming
language calls to database.
5
 PL/SQL's general syntax is based on that of ADA and Pascal
programming language.
 Apart from Oracle, PL/SQL is available in TimesTen in-
memory database and IBM DB2.

Features and advantages of PL/SQL

 It offers extensive error checking.


 It offers numerous data types.
 It offers a variety of programming structures.
 It supports structured programming through functions and
procedures.
 It supports object-oriented programming.
 It supports the development of web applications and server
pages.
 SQL is the standard database language and PL/SQL is
strongly integrated with SQL.
 PL/SQL supports both static and dynamic SQL. Static SQL
supports DML operations and transaction control from
PL/SQL block. In Dynamic SQL, SQL allows embedding
DDL statements in PL/SQL blocks.
 PL/SQL allows sending an entire block of statements to the
database at one time. This reduces network traffic and
provides high performance for the applications.
 PL/SQL gives high productivity to programmers as it can
query, transform, and update data in a database.
 PL/SQL saves time on design and debugging by strong
features, such as exception handling, encapsulation, data
hiding, and object-oriented data types.
 Applications written in PL/SQL are fully portable.
 PL/SQL provides high security level.

PL/SQL — Environment Setup

In this session, we will discuss the Environment Setup of


PL/SQL.
6
PL/SQL is not a stand-alone programming language; it is a tool
within the Oracle programming environment.

SQL* Plus is an interactive tool that allows you to type SQL and
PL/SQL statements at the command prompt. These commands
are then sent to the database for processing.

Once the statements are processed, the results are sent back and
displayed on screen.

To run PL/SQL programs, you should have the Oracle RDBMS


Server installed in your machine. This will take care of the
execution of the SQL commands. The most recent version of
Oracle RDBMS is 11g where you can download it at oracle.com.

You will have to download either the 32-bit or the 64-bit version
of the installation as per your operating system. You will also use
similar steps on your operating system, does not matter if it is
Linux or Solaris.

After installation, it is now time to verify your installation. At the


command prompt, use the following command if you are using
Windows:

sqlplus "/ as sysdba"

7
You should have the SQL prompt where you will write your
PL/SQL commands and scripts:

Oracle SQL Developer is a free graphical tool that enhances


productivity and simplifies database development tasks.

• You can connect to any target Oracle database schema using


standard Oracle database authentication.

• You will use SQL Developer in this course.

SQL Developer, the visual tool for database development;


simplifies the following tasks:

• Browsing and managing database objects


• Executing SQL statements and scripts
• Editing and debugging PL/SQL statements
• Creating reports

8
Oracle SQL Developer Loading

9
Text Editor

Running large programs from the command prompt may land


you in inadvertently losing some of the work. It is always
recommended to use the command files.

To use the command files:

 Type your code in a text editor, like Notepad, Notepad+, or


EditPlus, etc.
 Save the file with the .sql extension in the home directory.
 Launch the SQL*Plus command prompt from the directory
where you created your PL/SQL file.
 Type @file_name at the SQL*Plus command prompt to
execute your program.

If you are not using a file to execute the PL/SQL scripts, then
simply copy your PL/SQL code and right-click on the black
window that displays the SQL prompt; use the paste option to
paste the complete code at the command prompt. Finally, just
press Enter to execute the code, if it is not already executed.

11

You might also like