0
0
PostgreSQLquery~10 mins

DELETE with RETURNING clause in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to delete rows from the table and return the deleted rows.

PostgreSQL
DELETE FROM employees WHERE department = 'Sales' [1];
Drag options to blanks, or click blank then click option'
ARETURNING *
BOUTPUT *
CFETCH *
DRETURN *
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT instead of RETURNING, which is not valid in PostgreSQL.
Using RETURN without RETURNING.
Using FETCH which is unrelated here.
2fill in blank
medium

Complete the code to delete employees older than 60 and return their names.

PostgreSQL
DELETE FROM employees WHERE age > 60 [1] name;
Drag options to blanks, or click blank then click option'
ARETURNING
BOUTPUT
CFETCH
DSELECT
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT or FETCH which are not valid in PostgreSQL DELETE.
Using SELECT after DELETE which is invalid syntax.
3fill in blank
hard

Fix the error in the DELETE statement to correctly return the deleted rows.

PostgreSQL
DELETE FROM orders WHERE order_date < '2023-01-01' [1];
Drag options to blanks, or click blank then click option'
AOUTPUT *
BRETURN *
CFETCH ALL
DRETURNING *
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT which is SQL Server syntax.
Using RETURN which is invalid here.
Using FETCH which is unrelated.
4fill in blank
hard

Fill both blanks to delete products with zero stock and return their id and name.

PostgreSQL
DELETE FROM products WHERE stock = 0 [1] id, [2];
Drag options to blanks, or click blank then click option'
ARETURNING
BOUTPUT
Cname
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT instead of RETURNING.
Using '*' when specific columns are requested.
Omitting the comma between columns.
5fill in blank
hard

Fill all three blanks to delete customers from 'Canada' and return their name and email.

PostgreSQL
DELETE FROM customers WHERE country = 'Canada' [1] [2], [3];
Drag options to blanks, or click blank then click option'
ARETURNING
Bid
Cemail
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT instead of RETURNING.
Mixing up column order.
Forgetting commas between columns.