Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

SQL is the language used to define relational database structures, change the data stored in them, and retrieve results. The key beginner distinction is that DDL defines tables and other structures, DML changes rows, and SELECT retrieves and shapes query results. This guide uses PostgreSQL-style examples; other database systems may differ in syntax or behavior.

What is the difference between DDL and DML in SQL?

A relational database organizes data into tables. A table has columns that describe the kinds of information it stores and rows that hold individual records. Think of a table as a container: DDL defines or changes the container, while DML changes the records inside it.

Category Purpose Example
DDL (Data Definition Language) Defines or changes database structures, such as tables and their columns. CREATE TABLE
DML (Data Manipulation Language) Adds, changes, or removes row data in existing structures. INSERT, UPDATE, DELETE
Querying, often called DQL Retrieves and shapes results without changing stored rows. SELECT

The labels help organize what SQL statements do; they are not a substitute for learning each command and the behavior of the database system you use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What does DQL mean?

DQL means Data Query Language. It is a common teaching label for SQL queries, especially statements written with SELECT. The terminology is not universal: some explanations distinguish DQL from DML, while others group querying more broadly with data statements. In this article, DQL refers to retrieving data with SELECT, and DML refers to data-changing commands.

PostgreSQL’s tutorial treats querying separately from updates and deletions, while its command reference lists SELECT alongside data-changing commands in the PostgreSQL command set. That difference in presentation is one reason not to treat the category boundary as a fixed rule. See the PostgreSQL 18 tutorial and PostgreSQL SQL Commands reference.

How do you create a table, insert data, and query it?

This small example uses a students table with an ID, a name, and a cohort year. The SQL is PostgreSQL-style and intended to illustrate the concepts.

1. Define the table with DDL

CREATE TABLE students (
  student_id integer,
  name text,
  cohort integer
);

CREATE TABLE defines the table and its columns. The column names identify the fields; the types, such as integer and text, describe the kinds of values they hold.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Add a row with DML

INSERT INTO students (student_id, name, cohort)
VALUES (1, 'Mina', 2026);

INSERT adds a row to the table. Here, the values correspond in order to the columns named in the statement.

3. Retrieve selected columns

SELECT name, cohort
FROM students;

SELECT asks the database to return the chosen columns from the table. It reads and shapes results; it does not change the stored row in this example.

4. Change a row with DML

UPDATE students
SET cohort = 2027
WHERE student_id = 1;

UPDATE changes existing row data. This example sets the cohort value for the row whose student ID is 1.

5. Remove a row with DML

DELETE FROM students
WHERE student_id = 1;

DELETE removes row data from the table. It does not define or remove the table structure itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should you learn after the basic commands?

A useful beginner sequence is the one followed by the PostgreSQL 18 tutorial: create tables, populate them, query data, combine related tables, summarize results, and then learn how to update and delete rows.

Joins

Joins combine related rows from multiple tables in a query. For example, a later version of a student database might keep course registrations in a separate table and join them to student records when displaying a report.

Aggregate functions

Aggregate functions summarize rows, such as calculating a count or another group-level result. They help answer questions about a set of records rather than simply returning each record individually.

Updates and deletions

Once you can query data, learn how data-changing statements behave in your database system. The examples above show their basic purpose, but real use requires understanding the command syntax and effects for the system and situation at hand.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Does SQL work the same way in every database?

SQL is implemented by database systems, and supported commands, syntax, and compatibility details can vary. The examples here are PostgreSQL-style, not a universal guarantee for every SQL database. PostgreSQL’s command reference documents commands supported by PostgreSQL and provides command-specific information about SQL-standard conformance and compatibility. Consult the documentation for your chosen database when syntax or behavior matters.

Can you learn SQL without programming experience?

Yes. The PostgreSQL 18 tutorial says it is intended as an introduction to PostgreSQL, relational database concepts, and SQL, and it assumes general computer knowledge rather than prior Unix or programming experience. You can begin by understanding tables and columns, then practice creating a table, adding rows, and querying them. The tutorial’s progression continues through joins, aggregates, updates, and deletions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.