# Types of SQL Statements

SQL StatementsExample
DMLSELECT, INSERT, UPDATE, DELETE
DDLCREATE, ALTER, DROP
DCLGRANT, REVOKE
TCLBEGIN, TRAN, COMMIT, ROLLBACK

# Data Manipulation Language (DML)

In Data Manipulation Language (DML), we have four different SQL statements, Select, Insert, Update and Delete.

SELECT statement is used to select records from the table, with or without a condition.

INSERT statement is used to insert a set of values into a database table. Insert statement is used with Values.

UPDATE statement is used to update existing values in a table, which is based on some condition.

DELETE statement is used to delete the existing record in the table, which is based on some condition.

# Data Definition Language (DDL)

In Data Definition Language (DDL), we have three different SQL statements.

CREATE statement is used to create a new table in an existing database. CREATE statement is also used to create other database object such as a stored procedure, function, etc.

ALTER statement can add a column, modify a column, drop a column, rename a column or rename a table.

SQL DROP TABLE statement is used to remove a table definition and all the data, indexes, triggers, contraints and permission specification for the table.

# Data Control Language (DCL)

In Data Control Language (DCL), it defines the control over the data in the database. We have two different commands

GRANT is allowed to do the specified user to the specified tasks.

REVOKE is used to cancel previously granted or denied permissions.

# Transaction Control Language (TCL)

In Transaction Control Language (TCL), the commands are used to manage the transactions in the database. These are usedd to manage the changes made by DML statements. It also allows the statements to be grouped together into logical trasactions.

COMMIT command is used to permanently save any transaction into the database.

ROLLBACK command is used to restore the database for the last committed state. It's also used with a save point to jump to the save point.

SAVEPOINT command is used to temporarily save a transaction so that you can roll back to that point whenever necessary.