DBMigrationTools.which db allow transactional ddl and which not ?

Short rule (memorize this)

PostgreSQL supports transactional DDL; MySQL and Oracle mostly do not.

Now the precise breakdown 👇

PostgreSQL

Best-in-class transactional DDL

Supports rollback for most DDL:

BEGIN;
ALTER TABLE users ADD COLUMN age INT;
ROLLBACK; -- works

Transactional

  • CREATE TABLE
  • ALTER TABLE
  • DROP TABLE
  • ADD/DROP COLUMN
  • CREATE INDEX (normal)

NOT transactional (exceptions)

  • CREATE INDEX CONCURRENTLY
  • DROP INDEX CONCURRENTLY
  • VACUUM
  • some ALTER TYPE ... ADD VALUE (older versions)

📌 This is why Postgres is loved in modern backend systems.

⚠️ Databases with partial / limited transactional behavior

SQL Server

  • DDL runs inside transactions
  • But many operations auto-commit or acquire locks aggressively

Works

  • CREATE TABLE
  • ALTER TABLE

Problematic

  • Index rebuilds
  • Partition changes
  • Some schema ops ignore rollback semantics

⚠️ Transaction support exists, but behavior can surprise you.


❌ Databases that mostly do NOT support transactional DDL

MySQL / MariaDB

🚫 DDL auto-commits

BEGIN;
ALTER TABLE users ADD COLUMN age INT;
ROLLBACK; -- does nothing

Each DDL = implicit commit

Partial failures leave schema half-changed

Engine-dependent quirks (InnoDB helps for data, not schema)

Oracle

🚫 DDL always auto-commits

ALTER TABLE users ADD age NUMBER;
-- implicit commit before and after
  • No rollback possible
  • Even a failed DDL may commit previous changes

This is why Oracle migrations are very carefully staged.

Summary table (this is gold for interviews)

DatabaseTransactional DDL?Reality
PostgreSQL✅ YesBest support, with a few exceptions
SQL Server⚠️ PartialMostly transactional, many caveats
MySQL❌ NoDDL auto-commits
MariaDB❌ NoSame as MySQL
Oracle❌ NoDDL auto-commits
SQLite⚠️ PartialLimited, file-level locks

Why migration tools can’t “fix” this

Migration tools respect database semantics — they cannot add transactions where the DB doesn’t support them.

So:

  • Flyway/Liquibase wrap when possible
  • Disable transactions otherwise
  • Fail fast or leave partial state

Interview-ready answer (2 sentences)

PostgreSQL fully supports transactional DDL, allowing migrations to roll back safely, while MySQL and Oracle treat most DDL as auto-committing and non-transactional.
Migration tools adapt to these constraints, which is why non-transactional databases require extra care and forward-only recovery strategies.


Senior takeaway

Choose Postgres if you want safe schema evolution.
Choose Oracle/MySQL if you accept operational complexity.

This entry was posted in Без рубрики. Bookmark the permalink.