Difference Between SQL & PLSQL

Difference Between SQL & PLSQL

ยท

2 min read

SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database whereas PL/SQL is a combination of SQL along with the procedural features of programming languages.

What is PL/SQL

The PL/SQL stands for "Procedural Language extensions to Structured Query Language" and is the advanced version of SQL to perform more complex queries/operations on DB.

BEGIN
   DBMS_OUTPUT.PUT_LINE('Hello World!');
END;

Output

Hello World

What is SQL

Structure Query Language(SQL) is a database query language used for storing and managing data in Relational DBMS. The language was developed by IBM in 1970. It represents the set of relations (tables) in the database using DDL i.e. Data Definition Language.

SELECT COUNT(DISTINCT Country) FROM Customers;

Output

Tablename    Records
Customers    91
Categories    8
Employees    10
OrderDetails    518
Orders    196
Products    77
Shippers    3
Suppliers    29

Detailed Comparison

SQLPLSQL
Structured Query LanguageProcedural Query Language
Has no variablesHas many variables & data types
Executes single query at timeExecute block-wise
No loop and if controlHave loop, while and if controls
Declarative LanguageProcedural Langauge
Interacts with the database directlyDoesn't interact with server directly

Conclusion

SQL is a declarative language that specifies what data is needed. On the other hand, PL/SQL is a procedural language that specifies how data can be retrieved and what information is required.