DDL (Data Definition Language) is a language for defining the structure of a database (creating, modifying, deleting tables, schemas, indexes, etc.):
CREATE TABLE, ALTER TABLE, DROP TABLE.DML (Data Manipulation Language) is a language for manipulating data that works with the contents of tables (adding, modifying, deleting, retrieving rows):
INSERT, UPDATE, DELETE, SELECT.For instance, different users may have different rights solely for DML or solely for DDL:
-- DDL: create a table CREATE TABLE users ( id INT PRIMARY KEY, name VARCHAR(100) ); -- DML: insert data INSERT INTO users (id, name) VALUES (1, 'Ivan');
"Is it possible to roll back a DDL command (like DROP TABLE), if it was executed within an explicit transaction?"
Most DBMS (like PostgreSQL, Oracle) support transactions for DDL, but many do not allow rolling back DDL commands, even if they are explicitly wrapped in a transaction. In MySQL, DDL commands are always immediately committed.
BEGIN; DROP TABLE employees; ROLLBACK;
In most cases, the table will be permanently deleted despite the rollback.
Story
Loss of a table in the development environment after accidentally executing DROP TABLE — the command is irreversible, despite the rollback of the transaction.
Story
The organization granted administrative rights to a project that, due to a bug, made mass changes to the database schema through ALTER, resulting in prolonged service downtime and loss of orders.
Story
By denying DDL rights to newcomers, the team forgot that procedures for deploying migrations require DDL access — the release failed after several hours of investigation and emergency role elevation.