Published by Patrick Mutisya · 14 days ago
Show understanding that the industry standard for both DDL and DML is Structured Query Language (SQL).
Data Definition Language (DDL) consists of SQL statements that define, modify, and remove the structure of database objects such as tables, indexes, and constraints. DDL statements are typically executed by database administrators (DBAs) when designing or altering a database schema.
CREATE TABLE).ALTER TABLE).DROP INDEX).Data Manipulation Language (DML) comprises SQL statements used to retrieve, insert, modify, and delete the data stored within the structures defined by DDL. These statements are the core of everyday database interaction for developers and end‑users.
SQL (Structured Query Language) is the internationally recognised standard for both DDL and DML. It is defined by the ISO/IEC 9075 standard and is implemented (with minor vendor‑specific extensions) by all major relational database management systems (RDBMS) such as MySQL, PostgreSQL, Oracle, and Microsoft SQL Server. Because of its ubiquity, learning SQL provides a transferable skill across the industry.
| Category | Statement | Purpose | Typical Example |
|---|---|---|---|
| DDL | CREATE | Define a new database object | CREATE TABLE Student (id INT PRIMARY KEY, name \cdot ARCHAR(50)); |
| DDL | ALTER | Modify an existing object's definition | ALTER TABLE Student ADD COLUMN birthdate DATE; |
| DDL | DROP | Remove an object permanently | DROP TABLE Student; |
| DML | SELECT | Retrieve data | SELECT name FROM Student WHERE id = 10; |
| DML | INSERT | Add new rows | INSERT INTO Student (id, name) VALUES (10, 'Alice'); |
| DML | UPDATE | Change existing data | UPDATE Student SET name = 'Bob' WHERE id = 10; |
| DML | DELETE | Remove rows | DELETE FROM Student WHERE id = 10; |
CREATE TABLE, ALTER TABLE).INSERT).SELECT).Below is a simplified BNF‑style representation of the core DDL and DML syntax (presented in LaTeX for clarity):
\$\$\begin{aligned}
\text{ddl\stmt} &::= \text{CREATE}\ \text{TABLE}\ \text{id}\ (\text{col\def}\{,\text{col\_def}\}^*) \\
&\mid \text{ALTER}\ \text{TABLE}\ \text{id}\ \text{ADD}\ \text{col\_def} \\
&\mid \text{DROP}\ \text{TABLE}\ \text{id} \\
\\
\text{dml\stmt} &::= \text{SELECT}\ \text{select\list}\ \text{FROM}\ \text{id}\ \text{WHERE}\ \text{condition} \\
&\mid \text{INSERT}\ \text{INTO}\ \text{id}\ (\text{id}\{,\text{id}\}^*)\ \text{VALUES}\ (\text{value}\{,\text{value}\}^*) \\
&\mid \text{UPDATE}\ \text{id}\ \text{SET}\ \text{id}= \text{value}\{,\text{id}= \text{value}\}^*\ \text{WHERE}\ \text{condition} \\
&\mid \text{DELETE}\ \text{FROM}\ \text{id}\ \text{WHERE}\ \text{condition}
\end{aligned}\$\$
COMMIT or ROLLBACK can leave the database in an inconsistent state.TRUNCATE – it bypasses triggers and cannot be rolled back in some systems.