Generating test data with a query
Typing a few rows is fine for one check. A search, a report or a limit needs hundreds. Learn how a query can make rows, dates and names, and how to clean them up.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a copy machine for test rows. To test a school bell you do not walk a thousand pupils through the door. You copy a class list many times. The copies are clearly marked as copies.
Daily List is a to-do list app. Tom, the tester, needs many tasks for a paging test, and he needs to remove them in one step.
What it is: A makes many rows from one statement. A is a fixed prefix on every generated title, so a later delete can find them. A volume check uses enough rows to reach a limit, such as a screen that warns above 100 tasks. SQL (Structured Query Language) is the language the generator is written in. A table is a grid, a row is one item, and a column is one fact about that item. A generator is easy to mix up with a list of values you type by hand. The hand list is for exact cases. The generator is for a count.
Why it matters: Typing five rows cannot show what a list of 101 tasks does to the screen. Without markers or captured IDs, identifying this run’s thousand rows for cleanup is harder. The marker makes rows recognisable; safe deletion also requires run ownership and a checked predicate.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PLAIN WORDS · 2 in this section
- prefix
- letters or digits placed at the very start
- recognisable
- easy to identify
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB A copy machine that copies a class list many times.
- Make
- Run
- Remove
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The class list | A template row |
| The copy machine | A row generator |
| The mark on each copy | A test data marker |
| Counting the copies | A count check |
WHERE THIS PICTURE STOPS
- A copy is the same each time, but generated rows can vary.
- A copy machine uses paper, but a generator uses disk space.
- A school has a few classes, but a table can hold millions of rows.
HOOK
Mark, copy, count.
TELL A FRIEND
A copy machine: copies marked as copies.
OFTEN MIXED UP WITH Setting up and cleaning test data with SQL (Structured Query Language). That topic seeds and cleans up a few rows. This one makes many rows for volume checks.
PRACTISE AND KEEP
Sources for this topic — 3 sources
- Market practice
Set returning functions (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL reference: a series function returns a row for each step from a start to a stop, a negative or zero step behaves in set ways, and the date form takes an interval as the step (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Implementation-specific
PostgreSQL documentation ↗ — The PostgreSQL Global Development Group · PostgreSQL 18 official manual, opened 2026-11-06: functions-srf and SQLite series documentation. Supports only PostgreSQL behavior; earlier execution evidence remains separately versioned.
An implementation, not the standard — which is the point. ISO/IEC 9075-2 is paywalled, and this documents the same constructs in text anybody can open. Its isolation-level chapter attributes to the standard explicitly, so it can carry a standard-level claim as long as the citation says which document it is quoting.
Cited as market practice rather than an official standard by kind: an engine's manual is authoritative about that engine and is not the obligation. Where a question turns on behaviour PostgreSQL chose rather than behaviour SQL requires, the answer has to say so.
One correction carried here because it circulates widely: the sentence "The fundamental difference between WHERE and HAVING…", quoted all over the internet as PostgreSQL documentation, is not in the current documentation. It was searched for in the source tree and is not there.
Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.
Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.
Read from the
postgres/postgresdocumentation source tree (doc/src/sgml), which the project itself maintains and which carries the section ids the published URLs are derived from — so a cited section id can be checked against the rendered page. - Implementation-specific
SQLite official documentation — constraints, types and transactions ↗ — SQLite · SQLite rolling official documentation, opened 2026-11-06: foreignkeys.html, datatype3.html, lang_createtable.html, lang_transaction.html, isolation.html, cli.html, series.html and lang_createtrigger.html as relevant. Historical SQLite 3.40.1 results remain distinct from in-memory audit witnesses on 3.53.1.
Relevant primary pages opened 6 November2026; rolling documentation and CLI examples (3.54.0) are distinct from historical lesson runs3.40.1 and audit witnesses3.53.1. No file/connected database audit execution.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.