8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)

Bulk view disabled for Guests. View lessons individually.

Structured Query Language (SQL)

1. DDL vs. DML

In the 9618 syllabus, you must distinguish between commands that change the schema and those that change the content.

DDL (Data Definition)

Used to create or modify the structure of the database.

  • CREATE TABLE
  • ALTER TABLE
  • DROP TABLE
CREATE TABLE Students (
  ID INT PRIMARY KEY,
  Name VARCHAR(50)
);

DML (Data Manipulation)

Used to manage the data within the existing structure.

  • SELECT (Queries)
  • INSERT INTO
  • UPDATE
  • DELETE
SELECT Name
FROM Students
WHERE ID = 101;

2. Interactive SQL Workbench

Test your DDL and DML commands using the simulator we built. This tool maps your SQL queries to a visual relational model.

Query results will appear here...

Database Schema

No tables created yet.

A-Level Hint: Use PRIMARY KEY to ensure each record is unique!

πŸš€ SQL Quick Test Statements

Copy these one-liners into the tool above to see the database in action.

DDL CREATE TABLE Students (ID INT PRIMARY KEY, Name VARCHAR(50), Grade INT);
DML INSERT INTO Students (ID, Name, Grade) VALUES (1, 'Alice', 12), (2, 'Bob', 11), (3, 'Charlie', 12);
DML SELECT Name FROM Students WHERE Grade = 12;
DML UPDATE Students SET Grade = 12 WHERE Name = 'Bob';
DML SELECT COUNT(*) FROM Students;

3. Advanced Querying

For Paper 1, focus on these specific clauses:

  • INNER JOIN: To combine records from two tables based on a matching attribute.
  • ORDER BY: Sort results ASC (Ascending) or DESC (Descending).
  • SUM / COUNT / AVG: Aggregate functions for data analysis.
⚠️ Exam Tip: When writing UPDATE or DELETE, always remember the WHERE clause. Without it, you will update or delete every single row in the tableβ€”a common mistake in exams and real-world production!