WeLearn

Grade 12 Information Technology · Lesson 3.2

Database Manipulation Using SQL

Unit 3: Database Management System

SQL (Structured Query Language) is the standard language for working with relational databases. It is declarative: you state what result you want, and the DBMS works out how to get it. SQL commands are grouped into the Data Definition Language (DDL) for defining structure (CREATE, ALTER, DROP) and the Data Manipulation Language (DML) for working with data (INSERT, UPDATE, DELETE, SELECT). Keywords are not case-sensitive, but writing them in capitals makes code easier to read; statements usually end with a semicolon.

Key terms

SQL
standard language for relational databases
DDL
commands that define structure (CREATE, ALTER, DROP)
DML
commands that change or query data (INSERT, UPDATE, DELETE, SELECT)
Query
a request for data
WHERE clause
a condition that filters rows
Aggregate function
COUNT, SUM, AVG, MIN, MAX
JOIN
combining rows from related tables
All Grade 12 Information Technology key terms →

Summary

  • SQL is the standard language for relational databases.
  • DDL defines structure; DML inserts, updates, deletes and queries.
  • SELECT ... FROM ... WHERE ... ORDER BY / GROUP BY retrieves data.
  • JOIN combines related tables via keys.

In everyday life: When you check national exam results online by entering your registration number, the website runs an SQL SELECT query with a WHERE condition on that number.

Check yourself

  • Write SQL to add a student (ID 7, 'Hana', Grade 12).
  • What happens if you run DELETE FROM Students; with no WHERE?
  • Write a query counting the students in each grade.

Practice questions

  1. 1. Which SQL command is used to retrieve data from a table?

    • A. INSERT
    • B. UPDATE
    • C. SELECT
    • D. CREATE
    Show answer

    Answer: SELECT

    SELECT queries data; INSERT adds rows, UPDATE changes rows and CREATE defines new tables.

  2. 2. What does DELETE FROM Students; (with no WHERE clause) do?

    • A. Deletes the table structure
    • B. Deletes all rows in Students
    • C. Deletes only the first row
    • D. Gives a syntax error
    Show answer

    Answer: Deletes all rows in Students

    Without a WHERE condition, DELETE applies to every row, emptying the table while keeping its structure.

On WeLearn

The full lesson: reading notes, worked examples, class activities and the Unit 3 quiz

Study Database Manipulation Using SQL on WeLearn

Teach Database Manipulation Using SQL with WeLearn

We will bring a demo to your school: a lesson on your interactive TV, a virtual lab and a classroom game, with your own teachers.