Types of SQL Statements in MS SQL Server

By | 9th July 2019

There are different types of statements that can be executed in SQL Server for different purposes. These are basically categorized into four types

  1. DDL – Data Definition Language
  2. DML – Data Manipulation Language
  3. DCL – Data Control Language
  4. TCL – Transaction Control Language
Pic to show types of SQL commands

DDL(Data Definition Language)

The name itself suggests that it defines the structure of the database objects.

That is, it is used to create or modify the database or its objects. Some of the DDL commands are 

CREATE – Creates a database or its objects like table, view, SP, etc. 

ALTER – Modifies the structure of the DB or its objects. 

DROP – Drops the structure of the DB or its objects. 

TRUNCATE – Deletes the data from the table as well as the space allocated for the records. The structure of table remains same. 

RENAME – Renames an object. 

DML(Data Manipulation Language)

It deals with the retrieval and manipulation of the data stored in tables. Some of the SQL DML commands are 

SELECT – Retrieves data from a table. 

INSERT – Inserts data into a table. 

UPDATE – Updates existing data in a table. 

DELETE – Deletes data from the table. 

MERGE – Performs insert or update operation. 

DCL(Data Control Language)

It deals with the permissions and privileges of the objects. Two DCL commands are  

GRANT – Provides user access to the database or its objects. 

REVOKE – Restricts the user access to the database or its objects. 

TCL(Transaction Control Language)

It deals with the transaction within the database. Some of the TCL commands are 

COMMIT – Used to store the changes performed using a transaction. 

ROLLBACK – Used to revert the changes up to the last committed state in case of any error. 

SAVEPOINT – Used to roll the transaction back to a certain point. 

Also, check “Create table using SELECT in MS SQL Server

Reference – SQL Server statements

Leave a Reply

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