What are the types of SQL commands – Complete

What are the different types of commands in SQL, divided based on the type of operation they perform with simple explanation.

There are five types of commands in SQL based on the type of operation they perform.

DDL or Data Definition Language

Used in defining or manipulating database schema. These are used for creating, modifying, and dropping the structure of database objects such as tables.

CREATE TABLE | DATABASE <object_name>
ALTER TABLE <table_name>
DROP TABLE | DATABASE <object_name>

DML or Data Modification Language

Used in creating, updating or deleting data from the database objects such as tables.

INSERT INTO TABLE <table_name>
UPDATE <table_name> SET <column_name>=<new_value>
DELETE [ <column_name> | * ] FROM <table_name>

DCL or Data Control Language

Used enforce access control to data within the database or database objects.

GRANT <previlige_name> ON <object_name> TO <user_name>
REVOKE <previlige_name> ON <object_name> FROM <user_name>

TCL or Transaction Control Language

Used to enforce control on transactions within a database object which might result in a change in the state of data within the database objects.

COMMIT
ROLLBACK [ TO save_point_name ]
SAVEPOINT save_point_name

DQL or Data Query Language

Used for querying data from database objects. SELECT query is the only single command which can result in records from Database Objects such as tables, views etc and can be subject to projection.

The following table represents the command types and the SQL commands –

Command TypeSQL Commands
Data Definition LanguageCREATE, ALTER, DROP
Data Modification LanguageINSERT, UPDATE, DELETE
Data Control LanguageGRANT, REVOKE
Transaction Control LanguageCOMMIT, ROLLBACK, SAVEPOINT
Data Query LanguageSELECT
Ram
Ram

I'm a full-stack developer and a software enthusiast who likes to play around with cloud and tech stack out of curiosity. You can connect with me on Medium, Twitter or LinkedIn.

Privacy Overview
Referbruv

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

3rd Party Cookies

This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.

Keeping this cookie enabled helps us to improve our website.