Tables and basic queries

What a database is, how to create tables and add rows, and how to choose, sort and de-duplicate the rows a query returns.

About 9 hours of study

Learning objectives

Lessons

  1. 1

    Databases and tables

    What a database is, why programs keep data in one instead of plain files, and how a table holds data in rows and columns.

  2. 2

    Creating tables and adding rows

    CREATE TABLE with column types and defaults, INSERT one row or many, NULL for a missing value, and ALTER TABLE and DROP TABLE.

  3. 3

    Choosing rows and columns: SELECT and WHERE

    Pick columns and calculate new ones with SELECT; keep only the rows you want with WHERE, AND, OR, BETWEEN, IN and LIKE; and handle NULL with IS NULL.

  4. 4

    Sorting, limiting and DISTINCT

    ORDER BY one or more columns, LIMIT and OFFSET for the top rows and for pages, and DISTINCT to remove repeated rows.

Module practice

Module quiz

1. In a table of books, what does one row hold?
2. Which statement adds rows to a table?
3. What does NULL mean?
4. Which condition finds the rows where phone has no value?
5. What does WHERE city = 'Dhaka' OR city = 'Sylhet' AND marks > 80 mean?
6. ORDER BY marks DESC LIMIT 2 OFFSET 2 returns which rows?
7. Why can ORDER BY use a name made with AS in SELECT, while WHERE cannot?

Changing and summarising data ›