Structured Query Language
Structured Query Language
SQL commands are like instructions to a table. It is used to interact with the
database with some operations. It is also used to perform specific tasks,
functions, and queries of data. SQL can perform various tasks like creating a
table, adding data to tables, dropping the table, modifying the table, set
permission for users.
These SQL commands are mainly categorized into five categories:
1. DDL – Data Definition Language
2. DML – Data Manipulation Language
3. DCL – Data Control Language
4. TCL – Transaction Control Language
Data Definition Language actually consists of the SQL commands that can
be used to define the database schema. It simply deals with descriptions of
the database schema and is used to create and modify the structure of
database objects in the database. DDL is a set of SQL commands used to
create, modify, and delete database structures but not data. These
commands are normally not used by a general user, who should be
accessing the database via an application.
List of DDL commands:
DML
The SQL commands that deal with the manipulation of data present in the
database belong to DML or Data Manipulation Language and this includes
most of the SQL statements. It is the component of the SQL statement that
controls access to data and to the database. Basically, DCL statements are
grouped with DML statements.
List of DML commands:
DCL
DCL includes commands such as GRANT and REVOKE which mainly deal
with the rights, permissions, and other controls of the database system.
List of DCL commands:
GRANT: This command gives users access privileges to the database.
Syntax:
GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_US
ER;
REVOKE: This command withdraws the user’s access privileges given by
using the GRANT command.
TCL
Transactions group a set of tasks into a single execution unit. Each
transaction begins with a specific task and ends when all the tasks in the
group are successfully completed. If any of the tasks fail, the transaction
fails. Therefore, a transaction has only two results: success or failure. You
can explore more about transactions here. Hence, the following TCL
commands are used to control the execution of a transaction:
BEGIN: Opens a Transaction.
COMMIT: Commits a Transaction.
Syntax:
COMMIT;