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:
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:
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.
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:
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: