October 8, 2024
sql-database

What are the SQL statements?

This article describes about SQL statements. Summary of the article:

  • What are the SQL statements?
  • Data Definition Language (DDL) Statements
  • Data Manipulation Language (DML) Statements
  • Data Control Language (DCL) Statements
  • Transaction Control (TCL) Statements
  • Session Control Statements
  • System Control Statement
  • Embedded SQL Statements
  • Data Definition Language (DDL) Statements
  • Data Manipulation Language (DML) Statements
  • Data Control Language (DCL) Statements
  • Transaction Control (TCL) Statements
  • Session Control Statements
  • System Control Statement
  • Embedded SQL Statements

Data Definition Language (DDL)
DDL is a computer language used to define the database structure or schema. It is used to create and modify the structure of database objects in database.
The DDL Statements are:

  • CREATE – to create objects in the database
  • ALTER – alters the structure of the database
  • DROP – delete objects from the database
  • TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
  • COMMENT – add comments to the data dictionary
  • RENAME – rename an object

Data Manipulation Language (DML)
DML is a computer language used to manipulate data in a database/schema objects. It is used to retrieve, store, modify, delete, insert and update data in database. The DML statements are:

  • SELECT – retrieve data from the a database
  • INSERT – insert data into a table
  • UPDATE – updates existing data within a table
  • DELETE – deletes all records from a table, the space for the records remain
  • MERGE – UPSERT operation (insert or update)
  • CALL – call a PL/SQL or Java subprogram
  • EXPLAIN PLAN – explain access path to data
  • LOCK TABLE – control concurrency

Data Control Language (DCL)
DCL is a computer language used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.
The DCL statements are:

  • GRANT – gives user’s access privileges to database
  • REVOKE – withdraw access privileges given with the GRANT command

Transaction Control (TCL)
TCL is used to manage the changes made by DML statements. The TCL statements are :

  • COMMIT – save work done
  • ROLLBACK – restore database to original since the last COMMIT
  • SAVEPOINT – identify a point in a transaction to which you can later roll back
  • SET TRANSACTION – Change transaction options like isolation level and what rollback segment to useransaction Control (TCL)
  • SET CONSTRAINT

Session Control Statements
Session control statements dynamically manage the properties of a user session. These statements do not implicitly commit the current transaction.PL/SQL does not support session control statements. The session control statements are:

  • ALTER SESSION
  • SET ROLE

System Control Statement
The single system control statement, ALTER SYSTEM, dynamically manages the properties of an Oracle database instance. This statement does not implicitly commit the current transaction and is not supported in PL/SQL.

Embedded SQL Statements
Embedded SQL statements place DDL, DML, and transaction control statements within a procedural language program. Embedded SQL is supported by the Oracle pre-compilers.

That’s all about SQL statements.

Rashedul Alam

I am a software engineer/architect, technology enthusiast, technology coach, blogger, travel photographer. I like to share my knowledge and technical stuff with others.

View all posts by Rashedul Alam →

Leave a Reply

Your email address will not be published. Required fields are marked *