PostgreSQL Database Quiz Questions

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

The TRUNCATE command in PostgreSQL can be used to remove all rows from a table without logging individual row deletions.

Q2
True / False

The TRUNCATE command in PostgreSQL can be rolled back if it is part of a transaction.

Q3
True / False

The TRUNCATE command can only be used on a single table at a time in PostgreSQL.

Q4
True / False

The TRUNCATE command will not fire any ON DELETE triggers defined on the table.

Q5
True / False

In PostgreSQL, using TRUNCATE on a table with foreign key references from other tables will succeed without any additional steps.

Q6
True / False

The TRUNCATE command resets any sequences associated with the table's columns back to their starting values.

Q7
True / False

TRUNCATE in PostgreSQL can be restricted by using a WHERE clause to limit the rows that are removed.

Q8
True / False

TRUNCATE is a part of Data Definition Language (DDL) in PostgreSQL.

Q9
True / False

The TRUNCATE command requires more locks compared to the DELETE command in PostgreSQL.

Q10
True / False

: In PostgreSQL, using TRUNCATE on a partitioned table will not affect its partitions.

Q11
Single Choice

What does the TRUNCATE command do in PostgreSQL?

Q12
Single Choice

Which of the following is true about the TRUNCATE command in PostgreSQL?

Q13
Single Choice

What is the main difference between DELETE and TRUNCATE in PostgreSQL?

Q14
Single Choice

Consider the following SQL statement in PostgreSQL:

SQL Code
TRUNCATE TABLE employees;
What will happen to the rows in the employees table?
Q15
Single Choice

Which of the following commands would you use to remove all rows from multiple tables in PostgreSQL?

SQL Code
TRUNCATE TABLE employees, departments;
Q16
Single Choice

What happens to the sequences associated with a table when you issue a TRUNCATE command in PostgreSQL with the RESTART IDENTITY option?

Q17
Single Choice

Consider the following PostgreSQL SQL command:

SQL Code
TRUNCATE TABLE employees CASCADE;
What does the CASCADE option do in this context?
Q18
Single Choice

If you have a foreign key relationship between two tables, and you execute TRUNCATE on the parent table in PostgreSQL, what must be true for the operation to succeed?

Q19
Single Choice

What is the impact of using TRUNCATE ... RESTART IDENTITY CASCADE in PostgreSQL?

Q20
Single Choice

Which of the following commands would you use to truncate all tables in a PostgreSQL schema called sales while ensuring all sequences are reset and any dependent tables are also truncated?

SQL Code
DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'sales') LOOP
 EXECUTE 'TRUNCATE TABLE sales.' || r.tablename || ' RESTART IDENTITY CASCADE';
END LOOP;
END $$;
Q21
Multiple Choice

Which SQL command truncates a table in PostgreSQL, removing all rows but keeping the table structure intact?

SQL Code
TRUNCATE TABLE employees;
Q22
Multiple Choice

Which SQL command truncates multiple tables in a single command in PostgreSQL?

SQL Code
TRUNCATE TABLE employees, departments;
Q23
Multiple Choice

Which SQL command truncates a table and cascades the truncation to related tables in PostgreSQL?

SQL Code
TRUNCATE TABLE orders CASCADE;
Q24
Multiple Choice

Which SQL command is used to truncate a table but restrict the operation if it has foreign key references in PostgreSQL?

SQL Code
TRUNCATE TABLE sales RESTRICT;
Q25
Multiple Choice

Which SQL command is used to truncate a table while restarting its associated sequence in PostgreSQL?

SQL Code
TRUNCATE TABLE inventory RESTART IDENTITY;
Q26
Multiple Choice

Which SQL command truncates a table and logs the operation for recovery purposes in PostgreSQL?

SQL Code
TRUNCATE TABLE logs WITH IDENTITY;
Q27
Multiple Choice

Which SQL command is used to truncate a table without affecting the associated sequences in PostgreSQL?

SQL Code
TRUNCATE TABLE transactions CONTINUE IDENTITY;
Q28
Multiple Choice

Which SQL command truncates a table and triggers associated foreign key actions in PostgreSQL?

SQL Code
TRUNCATE TABLE customers CASCADE;
Q29
Multiple Choice

Which SQL command is used to truncate a partitioned table along with all of its partitions in PostgreSQL?

SQL Code
TRUNCATE TABLE partitioned_sales;
Q30
Multiple Choice

Which SQL command is used to truncate a table in PostgreSQL and log the operation for auditing?

SQL Code
TRUNCATE TABLE audit_logs WITH IDENTITY;