SQL sandbox with the course database
The Shelf online-shop database from the course "SQL for Testers: A Working Day". Change the data and create tables: the reset button brings the database back to its original state.
- SQLite 3.49, the same as the check in QA Steps
- Tables: 7
- No sign-up; the database lives in this tab
Query the database
Tables and columns: click a name to insert it
- (, , , )
- (, , , , , , , , , , , , , , , , , )
- (, , , , , , , , , )
- (, , , , , )
- (, , , , , )
- (, , , )
- (, , , )
Where the same query gives a different answer
The SQL day course teaches on SQLite 3.49, the same engine as QA Steps and this sandbox. At work you will most often meet MySQL or PostgreSQL. Almost everything in the course works the same on all three, but in the rows below the answers differ. All three columns were run on the same Shelf database.
| What is compared | MySQL 8.4 | QA Steps and sandbox (SQLite 3.49) | PostgreSQL |
|---|---|---|---|
Letter case in comparison SELECT id, status FROM orders WHERE status = 'Paid'; | 8 rows: MySQL treats 'Paid' and 'paid' as the same | Empty: case matters | Empty, same as SQLite |
Accented letters SELECT 'café' = 'cafe' AS same; | 1: MySQL ignores accents, so café and cafe are equal | 0: they are different strings | false |
LIKE and letter case SELECT id, subject FROM support_tickets WHERE subject LIKE '%CHARGED%'; | 3 tickets: LIKE ignores case | 3 tickets: SQLite ignores case for Latin letters | Empty: LIKE is case-sensitive, and ILIKE searches without case |
Integer division SELECT 7 / 2 AS half; | 3.5000 | 3: the fraction is dropped | 3, same as SQLite |
Shape of an average SELECT AVG(amount_cents) AS avg_payment FROM payments; | 19726.6154 | 19726.615384615383 | 19726.615384615385 |
Joining strings with || SELECT 'a' || 'b' AS glued, CONCAT('a', 'b') AS same_everywhere; | 0: in MySQL || is a logical OR. CONCAT gives ab | ab and ab | ab and ab |
A column outside GROUP BY SELECT user_id, status, COUNT(*) AS orders_count
FROM orders
GROUP BY user_id; | Error 1055 | Runs and takes status from any row of the group | Error, same as MySQL |
Group order without ORDER BY SELECT status, COUNT(*) AS orders_count
FROM orders
GROUP BY status; | paid, cancelled, awaiting_payment: in the order they first appear in the table | awaiting_payment, cancelled, paid: alphabetical | Any order: without ORDER BY none is promised |
FULL OUTER JOIN SELECT o.id AS order_id, p.id AS payment_id
FROM orders o
FULL OUTER JOIN payments p ON p.order_id = o.id; | Error: MySQL has no full join, so it is built from LEFT JOIN, UNION and RIGHT JOIN | 17 rows | 17 rows |
Casting to an integer SELECT CAST(2.6 AS SIGNED) AS signed_int, CAST(2.6 AS INTEGER) AS integer_int; | AS SIGNED gives 3, and AS INTEGER gives an error | 3 and 2: AS SIGNED is rewritten to CAST(ROUND(x) AS INTEGER), and AS INTEGER drops the fraction | SIGNED is unknown, and AS INTEGER rounds to 3 |
TRUNCATE inside a transaction START TRANSACTION;
TRUNCATE TABLE payments;
ROLLBACK;
SELECT COUNT(*) AS payments_left FROM payments; | 0: TRUNCATE ends the transaction, so ROLLBACK brings nothing back | 13: TRUNCATE runs as DELETE, and ROLLBACK undoes it | 13: ROLLBACK brings the table back |
Foreign keys PRAGMA foreign_keys; | Enforced: the database rejects a row that points nowhere | Not enforced (0). In the sandbox, PRAGMA foreign_keys = ON; turns the check on | Enforced |
VARCHAR(n) length CREATE TABLE notes (title VARCHAR(5));
INSERT INTO notes VALUES ('far too long');
SELECT title FROM notes; | Error 1406: a string longer than n does not fit | Stores the whole string: SQLite does not check the length | Error, same as MySQL |
The empty value SELECT IFNULL(NULL, 0) AS a, COALESCE(NULL, 0) AS b; | Both functions work | Both functions work | There is no IFNULL, only COALESCE works |
Name of the current database SELECT DATABASE(); | The database name | Error: there is only one database, and no such function | There is no such function, use current_database() instead |
Error text SELECT nickname FROM users; | Unknown column 'nickname' in 'field list' | no such column: nickname | column "nickname" does not exist |
What is rewritten automatically
Queries written for MySQL are common in tutorials. So that they run on SQLite, the sandbox and the task check in QA Steps replace four constructs before running. Everything else runs as written.
START TRANSACTION→ BEGIN
TRUNCATE TABLE x→ DELETE FROM x
AUTO_INCREMENT→ removed: an INTEGER PRIMARY KEY numbers itself
CAST(x AS SIGNED)→ CAST(ROUND(x) AS INTEGER)
Where to learn next
The SQL course takes you through this database from your first SELECT to accepting a migration. The other courses on the platform teach testing as a whole, from theory to the resume and the interview.





