DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober 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 Now×
Skip to content
World desk2 min

DDL and DML: How a Database Defines Its Structure and Changes Its Data

DDL changes database structure; DML adds, changes, or removes table data. See the difference through practical SQL examples and PostgreSQL caveats.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

DDL defines a database’s structure; DML changes the data stored in it. In the room analogy, DDL designs the room and its shelves, while DML puts things on the shelves, changes them, or takes them away. The comparison is a teaching aid, not a formal definition of every SQL command.

What DDL and DML mean

DDL stands for data definition language. It covers SQL commands used to define or change database structures, such as tables. DML stands for data manipulation language: commands used to add, change, or remove data in those tables. PostgreSQL presents these topics separately in its documentation: Data Definition and Data Manipulation.

As an Amazon Associate I earn from qualifying purchases.

Think of a table as a room with shelves. DDL lays out the room and its shelves; DML changes what is stored on them. The analogy helps distinguish structure from contents, but database objects and SQL commands are more varied than a room.

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

How the commands differ

Question DDL DML
What does it change? Database structure or definitions Data stored in tables
Typical examples CREATE, ALTER, DROP INSERT, UPDATE, DELETE
Room analogy Design, modify, or remove the room or its shelves Add, change, or remove the room’s contents

These examples follow PostgreSQL’s SQL command reference. The labels are useful families, not a complete classification of SQL.

DDL: define or change database structure

CREATE TABLE defines a table

A table definition establishes a place for data and its structure. For example, CREATE TABLE defines a table in the database.

ALTER TABLE changes a table definition

Use ALTER TABLE to change an existing table’s definition. In the analogy, this is like changing the shelves rather than rearranging the items on them.

DROP TABLE removes a table

DROP TABLE removes the table object. This acts on the structure itself, rather than simply deleting a row from a table.

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

DML: change the data in tables

INSERT adds rows

INSERT creates rows in a table. PostgreSQL’s insertion documentation demonstrates adding data to a products table.

UPDATE changes rows

UPDATE changes data already held in a table. It does not redefine the table’s structure.

DELETE removes rows

DELETE removes data from a table. It is different from DROP TABLE: the former removes rows, while the latter removes the table object.

Not every SQL command is DDL or DML

DDL and DML explain two important kinds of SQL work, but they do not account for every command. PostgreSQL’s command reference also lists SELECT, transaction controls such as COMMIT and ROLLBACK, and access-control statements. Avoid assuming that every SQL statement fits neatly into one of these two labels.

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

Whether a command succeeds also depends on context

Transaction mode

In PostgreSQL, transaction mode can restrict commands. Its SET TRANSACTION documentation says a read-only transaction disallows specified data-changing commands, including INSERT, UPDATE, and DELETE, as well as structure-changing commands including CREATE, ALTER, and DROP, subject to documented exceptions. This is PostgreSQL behavior; do not treat it as a universal rule for every database.

Permissions

A command’s category does not grant permission to run it. PostgreSQL defines distinct privileges, including SELECT, INSERT, UPDATE, DELETE, and CREATE; which privileges apply depends on the database object. See its privileges documentation.

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 *

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
Crashes, No Sound, or Screen Glitches?Free driver scan

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.