Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1SELECT * FROM students WHERE studentId = 3; | AA 'before' check: view the row you plan to change so you know its original values. | |
| 2SELECT COUNT(*) FROM students; | BSELECT * FROM students WHERE studentId <> 1; | |
| 3After an UPDATE, query the changed row to confirm it now holds the expected value. | CThe UPDATE has no WHERE clause, so every row changed. The test only checked one row and missed the unintended changes to the other rows. | |
| 4To check that an UPDATE did not change other rows, select every row except the one you edited and compare with the before data. | DCounts the rows so you can check that an INSERT added one row and a DELETE removed one. | |
| 5DELETE FROM students WHERE studentId = 4; SELECT * FROM students WHERE studentId = 4; -- Test passed: 1 row returned | EAfter a DELETE the check query should return no rows. Returning a row means the delete failed, so this test should be marked as failed. | |
| 6UPDATE students SET points = 0; SELECT * FROM students WHERE studentId = 2; -- Test passed | FSELECT points FROM students WHERE studentId = 1; |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
SELECT * FROM students; — Run a SELECT before and after an INSERT, UPDATE or DELETE, then compare both results with the expected data and check that no other rows changed.SELECT * FROM students;
UPDATE students SET points = 130
WHERE studentId = 1;UPDATE students SET points = 130
WHERE studentId = 1;
SELECT * FROM students WHERE studentId = 1;DELETE FROM students WHERE studentId = 10;
SELECT COUNT(*) FROM students;UPDATE students SET house = 'Red'
WHERE studentId = 3;
SELECT * FROM students;UPDATE students SET points = 130
WHERE studentId = 1;
SELECT * FROM students WHERE studentId <> 1;