PostgreSQL Database Quiz Questions

Course Name:PostgreSQL
Chapter Name:Chapter 6 - DML (Data Manipulation Language)
Lesson Content Link:DELETE
Current Quiz Count:30
Progress
0%
Q1
True / False

In PostgreSQL, the DELETE statement is used to remove rows from a table.

Q2
True / False

You must specify a WHERE clause in a DELETE statement to remove rows from a table.

Q3
True / False

The DELETE statement can only be used on a single table in PostgreSQL.

Q4
True / False

In PostgreSQL, you can use a RETURNING clause with the DELETE statement to return deleted rows.

Q5
True / False

The DELETE statement in PostgreSQL can be rolled back if used within a transaction block.

Q6
True / False

You can use subqueries in the WHERE clause of a DELETE statement in PostgreSQL.

Q7
True / False

In PostgreSQL, the DELETE statement can reference multiple tables using the USING clause.

Q8
True / False

In PostgreSQL, you cannot use JOINs in a DELETE statement.

Q9
True / False

The DELETE statement in PostgreSQL can be used with CTE (Common Table Expressions).

Q10
True / False

In PostgreSQL, the DELETE statement with a RETURNING clause can be used to capture the old and new values of the deleted rows for auditing purposes.

Q11
Single Choice

What does the DELETE statement do in PostgreSQL?

Q12
Single Choice

Which of the following is the correct syntax to delete all rows from a table named employees in PostgreSQL?

Q13
Single Choice

What keyword is used in PostgreSQL to delete rows that meet a specific condition?

Q14
Single Choice

Which of the following DELETE statements will remove employees with a salary greater than 50000 in PostgreSQL?

Q15
Single Choice

In PostgreSQL, what happens if you execute the following command: DELETE FROM orders WHERE order_id IN (SELECT order_id FROM shipped_orders);?

Q16
Single Choice

Which of the following is true about using DELETE in PostgreSQL with a RETURNING clause?

Q17
Single Choice

What does the following PostgreSQL command do?

SQL Code
DELETE FROM products p
USING categories c
WHERE p.category_id = c.id AND c.name = 'Obsolete';
Q18
Single Choice

How can you ensure that a DELETE operation in PostgreSQL does not delete any rows if the subquery returns no results?

Q19
Single Choice

Given the following tables orders and customers, how would you delete all orders for customers in a specific city, 'New York'?

SQL Code
DELETE FROM orders
WHERE customer_id IN (
 SELECT id
 FROM customers
 WHERE city = 'New York'
);
Q20
Single Choice

What will the following PostgreSQL command do?

SQL Code
DELETE FROM inventory i
WHERE EXISTS (
 SELECT 1
 FROM warehouse w
 WHERE w.item_id = i.item_id
 AND w.stock < 0
);
Q21
Multiple Choice

Which SQL command deletes a single row from a PostgreSQL table based on a specific condition?

SQL Code
DELETE FROM employees
WHERE employee_id = 1;
Q22
Multiple Choice

Which SQL command deletes multiple rows from a PostgreSQL table that meet a specific condition?

SQL Code
DELETE FROM orders
WHERE order_date < '2023-01-01';
Q23
Multiple Choice

Which SQL command deletes rows in a PostgreSQL table based on a condition with a subquery?

SQL Code
DELETE FROM employees
WHERE department_id = (
 SELECT department_id FROM departments WHERE department_name = 'HR'
);
Q24
Multiple Choice

Which SQL command deletes all rows from a PostgreSQL table?

SQL Code
DELETE FROM customers;
Q25
Multiple Choice

Which SQL command deletes rows in a PostgreSQL table and returns the deleted rows using the RETURNING clause?

SQL Code
DELETE FROM employees
WHERE department_id = 2
RETURNING employee_id, first_name, last_name;
Q26
Multiple Choice

Which SQL command deletes rows from a table in PostgreSQL using a JOIN clause?

SQL Code
DELETE FROM orders o
USING customers c
WHERE o.customer_id = c.customer_id
AND c.customer_name = 'John Doe';
Q27
Multiple Choice

Which SQL command deletes rows from a PostgreSQL table where a certain value is NULL?

SQL Code
DELETE FROM orders
WHERE shipping_date IS NULL;
Q28
Multiple Choice

Which SQL command deletes rows from a PostgreSQL table based on a condition using EXISTS?

SQL Code
DELETE FROM employees e
WHERE EXISTS (
 SELECT 1 FROM departments d WHERE d.department_id = e.department_id AND d.department_name = 'HR'
);
Q29
Multiple Choice

Which SQL command deletes rows from a PostgreSQL table and logs the deleted data using the RETURNING clause?

SQL Code
DELETE FROM inventory
WHERE product_id = 404
RETURNING *;
Q30
Multiple Choice

Which SQL command deletes rows from a table in PostgreSQL using a CTE (Common Table Expression)?

SQL Code
WITH old_orders AS (
 SELECT order_id FROM orders WHERE order_date < '2022-01-01'
)
DELETE FROM orders
WHERE order_id IN (SELECT order_id FROM old_orders);