October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan 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 desk3 min

DDL and DML in SQL: What They Mean and How They Differ

DDL changes database structures and objects; DML retrieves or changes the data stored in them. See the key SQL commands, examples and important platform-specific caveats.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DDL defines or changes database objects; DML retrieves or changes the data stored in them. For example, CREATE TABLE defines a table, while INSERT, SELECT, UPDATE and DELETE work with its rows. The distinction is about what a statement acts on—not whether a particular database automatically commits it or allows it to be rolled back.

What DDL and DML mean

DDL stands for Data Definition Language. It describes SQL statements used to define or alter database structures and objects, such as tables. Microsoft’s SQL Server statement list includes CREATE, ALTER, DROP, RENAME and TRUNCATE TABLE in its DDL category. Microsoft’s Transact-SQL statement reference

As an Amazon Associate I earn from qualifying purchases.

DML stands for Data Manipulation Language. It covers statements used to retrieve or work with data in database objects. Microsoft lists INSERT, UPDATE, DELETE, SELECT, MERGE and BULK INSERT as SQL Server DML statements. Microsoft’s SQL Server queries documentation

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.

DDL vs. DML at a glance

Category What it affects Typical purpose Examples
DDL Database structure and objects Create, change, rename or remove objects CREATE, ALTER, DROP, TRUNCATE TABLE
DML Data stored in database objects Retrieve, add, change or remove data SELECT, INSERT, UPDATE, DELETE

A useful shorthand is: DDL changes the shape of the database; DML queries or changes its contents. The table lists examples documented for SQL Server; statement syntax and support can differ among database products.

Examples: defining a table and working with its rows

This illustrative sequence first creates a table, then inserts, retrieves and updates a row:

CREATE TABLE customers (
    customer_id INTEGER,
    name VARCHAR(100)
);

INSERT INTO customers (customer_id, name)
VALUES (1, 'Ari');

SELECT customer_id, name FROM customers;

UPDATE customers
SET name = 'Ari Lee'
WHERE customer_id = 1;

CREATE TABLE defines the database object, so it is DDL. The other statements operate on the table’s data, so they are DML. This example is for illustration: supported data types, constraints and exact syntax depend on the database system.

Common DDL statements

  • CREATE TABLE creates a table and defines its columns.
  • ALTER TABLE changes a table’s structure.
  • DROP TABLE removes the table object.
  • TRUNCATE TABLE is categorized as DDL in Microsoft’s SQL Server statement list; check your database’s documentation for its precise behavior.

Common DML statements

  • SELECT retrieves data.
  • INSERT adds rows.
  • UPDATE changes values in rows.
  • DELETE removes rows.
  • MERGE and BULK INSERT are also included in Microsoft’s SQL Server DML list.

Is SELECT DML or DQL?

In the SQL Server documentation and Oracle’s statement reference cited here, SELECT is classified as DML. Oracle describes it as a limited form of DML because it accesses data without changing it. Oracle Database 18 SQL Language Reference: Types of SQL Statements

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

Some courses and learning materials put querying in a separate category called DQL (Data Query Language). That is a teaching convention readers may encounter; it does not change what SELECT does. These vendor references establish how SQL Server and Oracle classify the statement, not one taxonomy used universally by every database or course.

DDL and DML do not determine transaction behavior

DDL and DML describe the kind of work a statement performs. They do not, by themselves, tell you whether a specific database will commit the statement automatically, let you roll it back, or require particular locks.

For example, Oracle Database 19c documentation says DML statements do not implicitly commit the current transaction. That is an Oracle-specific statement, not a rule to apply to every product. Oracle Database 19c Database Concepts: Transactions DDL transaction handling varies among database products and versions, so consult the documentation for the system you use before relying on commit or rollback behavior.

Locking can also depend on the database. Oracle Database 18 documentation says its CREATE, ALTER and DROP commands require exclusive access to the specified object; an open transaction on a table is one example of a condition that can cause ALTER TABLE to fail. This describes Oracle’s documented behavior, not a universal locking rule. Oracle Database 18 SQL Language Reference: Types of SQL Statements

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

How to handle schema-changing statements safely

DDL can alter or remove objects, so verify the statement and its target before executing it. Microsoft Support specifically warns that Access data-definition queries can alter or delete database objects without confirmation dialogs and advises making a backup copy of the tables involved. Microsoft Support: Create or modify tables or indexes by using a data-definition query

  • Check the database and object named in the statement, especially before using DROP or another destructive operation.
  • Use a safe test environment when appropriate, rather than experimenting on important production objects.
  • Back up important data before consequential schema edits, following guidance appropriate to your database platform.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.