Types Of SQL Statements

AdSense

What is SQL?

SQL stands for Structured Query Language, as it is the special purpose domain-specific language for querying data in Relational Database Management System (RDBMS).

Microsoft SQL Server, MySQL, Oracle, etc. use SQL for querying with slight syntax differences.

Types of SQL Statements

SQL statements are categorized into four different types of statements, which are

  1. DML (DATA MANIPULATION LANGUAGE)
  2. DDL (DATA DEFINITION LANGUAGE)
  3. DCL (DATA CONTROL LANGUAGE)
  4. TCL (TRANSACTION CONTROL LANGUAGE)

DML (DATA MANIPULATION LANGUAGE)

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
    • DELETE statement is used to delete the existing data in the table, which is based on some condition.

DDL (DATA DEFINITION LANGUAGE)

  • CREATE TABLE
  • ALTER TABLE
  • DROP TABLE
    • DROP TABLE statement is used to remove a table definition and all the data, indexes, triggers, constraints and permission specifications for the table.
  • TRUNCATE TABLE
    • TRUNCATE TABLE statement removes all rows from a table, but the table structure and its columns, constraints, indexes, and so on remain.
    • It’s similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.

DCL (DATA CONTROL LANGUAGE)

  • GRANT
    • Grant is allowed to do the specified user to the specified tasks.
  • REVOKE
    • It is used to cancel previously granted or denied permissions.

TCL (TRANSACTION CONTROL LANGUAGE)

The commands are used to manage the transactions in the database. These are used to manage the changes made by DML statements. It also allows the statements to be grouped together into logical transactions.

  • COMMIT
    • Commit command is used to permanently save any transaction into the database.
  • ROLLBACK
    • 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
    • SAVEPOINT command is used to temporarily save a transaction so that you can roll back to that point whenever necessary.

References:
Types Of SQL Statements With Examples