1. Home
  2. Docs
  3. SQL using PostgreSQL 12
  4. 1 SQL Basics using PostgreSQL 12
  5. 1.1 Types of Commands

1.1 Types of Commands

PostgreSQL consists of several commands, preferably called as SQL statements. The SQL statements can be used to perform almost all the database operations in PostgreSQL. Since, many things could be done using SQL, these commands are grouped into following components as per their usage.

  • DDL – Data Definition Language
  • DML – Data Manipulation Language
  • DQL – Data Query Language
  • DCL – Data Control Language
  • TCL – Transaction Control Language

1.2.1 Data Definition Language (DDL)

In PostgreSQL, tables are the only way to store and retrieve data. You can create a table using CREATE TABLE command in SQL. Different commands that fall into DDL are:

  • CREATE
  • ALTER
  • DROP
  • TRANCATE
  • RENAME

Other than tables, PostgreSQL database offers of many other objects. Click here to know about the objects available in a PostgreSQL database. All above mentioned DDL commands are used to define or modify database objects like Tables, Views, Sequences, Indexes, Synonyms and many more.

1.2.2 Data Manipulation Language (DML)

DML statements allow you to manipulate data within tables. SQL statements in PostgreSQL that fall into DML are:

  • INSERT
  • UPDATE
  • DELETE
  • MERGE

1.2.3 Data Query Language (DQL)

DQL or Data Retrieval Language (DRL) is used to fetch data from tables. Data fetching is done through SELECT statement.

  • SELECT

1.2.4 Data Control Language (DCL)

DCL statements allow database users the right or permission to access and manipulate data. These are done through:

  • GRANT
  • REVOKE

1.2.5 Transaction Control Language (TCL)

TCL statements commands are used to deal with transactions within the database. Below SQL statements fall into TCL:

  • COMMIT
  • ROLLBACK
  • SAVEPOINT
Was this article helpful to you? Yes No

How can we help?