October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

Introduction to SQL: DDL, DML, and Data Querying

Understand the difference between DDL, DML, and querying in SQL, then follow a beginner-friendly PostgreSQL-style example from table creation to changing data.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DDL defines the structure of a database, DML changes the data stored in it, and SELECT retrieves data for a query. The label DQL (Data Query Language) is often used for querying, but SQL references do not all classify SELECT the same way. The examples below use PostgreSQL-style SQL.

What is the difference between DDL and DML in SQL?

SQL works with relational data organized into tables. A table has columns that describe the kinds of information it holds and rows that contain individual records. The simplest distinction is about what a statement acts on:

As an Amazon Associate I earn from qualifying purchases.

  • DDL (Data Definition Language) defines or changes database structures, such as tables and their columns.
  • DML (Data Manipulation Language) adds, changes, or removes rows within those structures.
  • Querying retrieves and shapes results from stored data. Many beginner explanations call this DQL.

Think of DDL as defining the container, DML as changing its contents, and a query as reading selected information from it. These labels help organize SQL concepts, but the classification boundary is not universal.

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

How to create a table and add a row

Consider a small table of students. In PostgreSQL-style SQL, CREATE TABLE defines the table and its columns; it does not add a student record.

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

This is DDL: it establishes a structure with an integer student ID, a text name, and an integer cohort. To add a row to that existing table, use INSERT:

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

INSERT is DML because it changes the stored row data rather than defining the table.

What does DQL mean, and what does SELECT do?

DQL stands for Data Query Language. It is a useful beginner label for statements that retrieve data, especially SELECT. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
SELECT name, cohort
FROM students;

This asks for the name and cohort values from the students table. SELECT retrieves query results; it does not change the stored rows. Some SQL classifications group SELECT with data statements rather than treating DQL as a separate category. PostgreSQL’s tutorial presents querying separately from updates and deletions, while its command reference includes SELECT among PostgreSQL commands. See the PostgreSQL SQL Commands reference for the system’s command list.

How do UPDATE and DELETE change table data?

To change an existing row, use UPDATE. To remove a row, use DELETE. Both are DML:

UPDATE students
SET cohort = 2027
WHERE student_id = 1;

DELETE FROM students
WHERE student_id = 1;

In the example, the update changes Mina’s cohort value, and the delete removes the row with student ID 1. These examples show the basic purpose of each command; consult the documentation for the database system you use when syntax or behavior matters.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What should you learn next?

A practical learning sequence moves from defining a table to working with the information in it. PostgreSQL 18’s tutorial follows this general progression:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Learn how tables and columns represent relational data.
  2. Create a table with CREATE TABLE.
  3. Populate it with rows using INSERT.
  4. Retrieve data with SELECT.
  5. Combine related tables with joins.
  6. Summarize data with aggregate functions.
  7. Change and remove rows with UPDATE and DELETE.

The PostgreSQL 18 SQL tutorial covers these topics and says it assumes general computer knowledge, but no particular Unix or programming experience. It is an introduction to PostgreSQL, relational database concepts, and SQL—not a guarantee that every database system supports identical syntax or behavior. PostgreSQL’s command reference documents commands supported by PostgreSQL and points to command-specific compatibility details.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.