Question:

Explain the different types of SQL commands.

Show Hint

- DDL = Structure - DML = Data - DCL = Permissions - TCL = Transactions
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

SQL (Structured Query Language) commands are categorized into five main types based on their functionality:

DDL (Data Definition Language): Used to define and manage the structure of the database and its objects (like tables).

\text{CREATE}: To create new tables, databases, or other objects.
\text{ALTER}: To modify the structure of an existing object.
\text{DROP}: To permanently delete an object.
\text{TRUNCATE}: To remove all records from a table, but not the table itself.

DML (Data Manipulation Language): Used for managing the data within the schema objects.

\text{SELECT}: To retrieve data from the database.
\text{INSERT}: To add new data into a table.
\text{UPDATE}: To modify existing data.
\text{DELETE}: To remove data from a table.

DCL (Data Control Language): Used to control access rights and permissions on the database.

\text{GRANT}: To give user access privileges.
\text{REVOKE}: To take back permissions from a user.

TCL (Transaction Control Language): Used to manage transactions in the database.

\text{COMMIT}: To save the work done in a transaction.
\text{ROLLBACK}: To restore the database to the last committed state.
\text{SAVEPOINT}: To create points within a transaction to which you can later roll back.

DQL (Data Query Language): While often considered part of DML, some classify it separately. Its sole purpose is to fetch data.

\text{SELECT}: Used to query the database.

Was this answer helpful?
0
0