Databases & Backend

SQL DDL vs DML Explained

NoSQL was supposed to bury SQL. Yet here we are, still crafting tables with CREATE and slicing data via WHERE. One developer's first-week epiphany reveals why.

SQL DDL and DML commands creating and populating a students table

Key Takeaways

  • DDL builds database structure; DML manipulates the data within it.
  • WHERE with LIKE, IN, BETWEEN filters precisely, powering efficient queries.
  • CASE WHEN adds logic, turning raw numbers into insights — essential for real apps.

Everyone figured NoSQL would sweep relational databases into obscurity — document stores, key-values, graphs, all promising speed without the schema rigidity. Developers ditched SQL for MongoDB’s flexibility, chasing microservices dreams. But.

Reality hit. AI models crave clean, structured data. LLMs hallucinate less on relational joins than messy JSON blobs. And suddenly, SQL’s back — not as legacy, but as the architectural spine for data pipelines feeding GPTs and beyond.

This shift? It’s architectural. Not hype. Relational models enforce integrity at the core, preventing the data swamps that doom 80% of analytics projects.

What Separates DDL from DML — And Why It Sticks

DDL. Data Definition Language. CREATE, ALTER, DROP. These sculpt the database’s skeleton — tables, indexes, constraints. Think of it as the blueprint phase.

DML? Data Manipulation Language. INSERT, UPDATE, DELETE. That’s the flesh — records flowing in, tweaking, vanishing.

Here’s the original breakdown that nailed it:

Aspect DDL (Data Definition Language) DML (Data Manipulation Language)
Purpose Defines database structure Manipulates data in tables
Commands CREATE, ALTER, DROP INSERT, UPDATE, DELETE
Effect Changes schema Changes records/data
Example CREATE TABLE students INSERT INTO students VALUES (…)

Spot on. No fluff.

In a recent assignment — raw, hands-on — someone spun up tables for students, exam results, subjects. CREATE TABLE students (id INT PRIMARY KEY, name VARCHAR(100)); boom, structure born.

But here’s my unique angle: this mirrors the 1990s web explosion. Back then, SQL powered eBay’s auctions, Amazon’s catalogs. No fancy ORMs. Just raw DDL forging schemas that scaled to billions. Today? Same playbook for Snowflake warehouses or Postgres under Kubernetes. History doesn’t repeat — it rhymes in ACID transactions.

How Did WHERE and LIKE Turn Chaos into Insight?

INSERT adds rows. Fine. But without filters? Data deluge.

Enter WHERE. The scalpel.

Operators: =, >, <. Simple. Then BETWEEN for ranges — marks BETWEEN 50 AND 80. IN for lists: city IN (‘Nairobi’, ‘Mombasa’, ‘Kisumu’). Power.

LIKE? Pattern wizardry. ‘A%’ — starts with A. ‘%Studies%’ — anywhere “Studies” lurks. It’s regex lite, baked into every engine from MySQL to BigQuery.

One slip — missing comma in multi-row INSERT — and errors cascade. Syntax unforgiving. That’s SQL’s tough love, training precision from day one.

Architecturally? WHERE use indexes under the hood. B-trees slicing query times from hours to milliseconds. No wonder it’s the query optimizer’s best friend.

Why Does CASE WHEN Feel Like SQL’s Hidden Superpower?

Raw marks: 92, 65, 48. Meh.

CASE WHEN marks >= 80 THEN ‘Distinction’ WHEN marks >= 60 THEN ‘Merit’ … ELSE ‘Fail’ END. Suddenly, categories. Actionable.

This isn’t fluff. It’s computed columns in flight — no ETL bloat. In warehouses, it bins data for ML features on-the-fly.

Challenging? Yeah. Nesting conditions trips newbies. But master it, and you’re transforming dumps into dashboards.

CASE WHEN was used to create conditional logic in SQL queries. It helped transform raw data into meaningful categories. For example, exam marks were classified into: Distinction, Merit, Pass, Fail based on score ranges.

That quote captures the thrill. First SELECT * FROM exam_results; rows materialize. Magic.

Is SQL’s Syntax Strictness a Bug or Feature?

Small errors — no comma, wrong quote — halt everything. Frustrating for week-one learners.

But dig deeper. It’s deliberate. Databases guard petabytes; one bad UPDATE without WHERE wipes millions. Safety first.

Compare to NoSQL: flexible schemas breed inconsistencies. 70% of data engineers’ time? Cleaning NoSQL exports for analytics. SQL? Built-in guards.

Prediction: With vector databases layering on Postgres extensions like pgvector, SQL absorbs AI workloads. No migration pain. Hybrid future.

Corporate spin? None here — this is practitioner truth. No vendor fluff.

Real-world? Update student’s city. DELETE rogue result_id 9. Routine ops powering banks, hospitals.

Why SQL Fundamentals Trump Hype Cycles Every Time

First week: fascination. Tables from void. Data breathing life.

It’s addictive. Structured thinking.

NoSQL fad? Faded for transactional cores. SQL persists — 50+ years, zero retirement signs.

For devs: Skip basics, pay later. ORMs abstract too much; know the metal.

The most interesting part was creating tables from scratch and adding data into them. Seeing the results using SELECT * was fascinating.

Pure joy. Echoes my first query, 15 years back.

Challenges build muscle. Multi-row INSERTs demand care. WHERE clauses sharpen logic.

Bottom line: SQL isn’t dying. It’s evolving — serverless Aurora, columnar for analytics. Foundations eternal.


🧬 Related Insights

Frequently Asked Questions

What is the difference between SQL DDL and DML?

DDL defines structure (CREATE, DROP). DML handles data (INSERT, UPDATE).

How do you use LIKE and IN in SQL WHERE clauses?

LIKE for patterns: ‘A%’. IN for lists: city IN (‘NYC’, ‘LA’).

What does CASE WHEN do in SQL?

Conditional logic: CASE WHEN condition THEN value ELSE other END. Bins data smartly.

Priya Sundaram
Written by

Hardware and infrastructure reporter. Tracks GPU wars, chip design, and the compute economy.

Frequently asked questions

What is the difference between SQL DDL and DML?
DDL defines structure (CREATE, DROP). DML handles data (INSERT, UPDATE).
How do you use LIKE and IN in SQL WHERE clauses?
LIKE for patterns: 'A%'. IN for lists: city IN ('NYC', 'LA').
What does CASE WHEN do in SQL?
Conditional logic: CASE WHEN condition THEN value ELSE other END. Bins data smartly.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.