PROGRAM 11
P11: I n t r o d u c t i o n o f P L / S Q L . D i f f e r e n t i a t e b e t w e e n S Q L v s
PL/SQL. Implement by example
PL/SQL:
PL/SQL (Procedural Language/Structured Query Language) is an extension of SQL (Structured
Query Language) that integrates procedural constructs, allowing for the creation of powerful and
complex database applications. Developed by Oracle Corporation, PL/SQL enables users to
manipulate data, define business logic, and automate tasks within the Oracle database environment.
With its procedural capabilities such as loops, conditions, and exception handling, PL/SQL
facilitates the creation of modular, maintainable, and efficient code for tasks ranging from simple
data retrieval to intricate data processing and manipulation, making it a fundamental tool for
database developers and administrators alike.
DIFFERENCE BETWEEN PL/SQL AND SQL:
Sr. Basis of SQL PL/SQL
No. Comparison
1. Definition It is a database Structured Query It is a database programming
Language. language using SQL.
2. Variables Variables, constraints, and data
Variables are not available in SQL. types features are available in
PL/SQL.
3. Control structures Control Structures are available
No Supported Control Structures like for
like, for loop, while loop, if, and
loop, if, and other.
other.
4. Nature of It is an application-oriented
It is a Data-oriented language.
Orientation language.
5. Operations PL/SQL block performs Group of
Query performs the single operation in
Operation as a single block resulting
SQL.
in reduced network traffic.
6. Declarative/
Procedural SQL is a declarative language. PL/SQL is a procedural language.
Language
7. Embed SQL can be embedded in PL/SQL. PL/SQL can’t be embedded in SQL.
8. Interaction with It directly interacts with the database It does not interact directly with the
Server server. database server.
9. Exception SQL does not provide error and PL/SQL provides error and
Handling exception handling. exception handling.
Sr. Basis of SQL PL/SQL
No. Comparison
10. Writes It is used to write queries using DDL
The code blocks, functions,
(Data Definition Language) and DML
procedures triggers, and packages
(Data Manipulation Language)
can be written using PL/SQL.
statements.
11. Processing Speed SQL does not offer a high processing PL/SQL offers a high processing
speed for voluminous data. speed for voluminous data.
12. Application You can use PL/SQL to develop
You can fetch, alter, add, delete, or
applications that show information
manipulate data in a database using SQL.
from SQL in a logical manner.
SYNTAX:
CREATE VIEW <view_name> AS SELECT <set of fields>
FROM relation_name WHERE (Condition)
QUERY:
CREATE VIEW view_employee AS SELECT * FROM employee WHERE (salary >
200000)
SELECT * FROM view_employee
RESULT: