SQL Commands | DDL , DQL, DML, DCL, TCL

SQL is a Structured Query Language used to perform various operations on our databases. By using SQL, we can create databases, tables, columns, and many other things.

Types of SQL commands :

  1. DDL (Data Definition Language)
  2. DQL (Data Query Language)
  3. DML (Data Manipulation Language)
  4. DCL (Data Control Language)
  5. TCL (Transaction Control Language)

DDL

DDL stands for Data Definition Language, which can be used to define the database schema. The commands that come under DDL are:

  • CREATE (to create a new database and table)
  • ALTER (to add a new column to our existing table)
  • DROP (to drop an entire table with its structure, i.e., column names)
  • TRUNCATE (to delete all the values from a table, but the column names remain the same)

DQL

DQL stands for Data Query Language, which can be used for performing queries on data within schema objects. The command that comes under DQL is:

  • SELECT (to retrieve data from databases)

DML

DML stands for Data Manipulation Language and can be used to perform data manipulation. The commands that come under DML are:

  • INSERT (to insert data into a table)
  • UPDATE (to update existing data in a table)
  • DELETE (to delete a particular record from a table)

DCL

DCL stands for Data Control Language and can be used to provide different user accesses to store data. The commands that come under DCL are:

  • GRANT (to grant access to database objects like tables, views, etc.)
  • REVOKE (to remove someone's access from database objects)

TCL

TCL stands for Transaction Control Language and can be used to maintain the consistency of databases. The commands that come under TCL are:

  • COMMIT (saves all transaction-related changes permanently)
  • ROLLBACK (rolling back our transaction to the previous SAVE POINT)
  • SAVE POINT (temporary changes rollback or save)

Comments