Challenge - 5 Problems
Partition Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of attaching a partition
Given a partitioned table
What will be the result of this command?
sales and a child table sales_2023 with matching structure, what is the output of the following command?ALTER TABLE sales ATTACH PARTITION sales_2023 FOR VALUES FROM ('2023-01-01') TO ('2024-01-01');What will be the result of this command?
PostgreSQL
ALTER TABLE sales ATTACH PARTITION sales_2023 FOR VALUES FROM ('2023-01-01') TO ('2024-01-01');
Attempts:
2 left
💡 Hint
Check if the partition range matches the parent table's partitioning scheme.
✗ Incorrect
The command attaches the child table sales_2023 as a partition for the specified range. If the range matches and no conflicts exist, it succeeds.
❓ query_result
intermediate2:00remaining
Result of detaching a partition
What happens when you run this command on a partitioned table
orders with a partition orders_2022 attached?ALTER TABLE orders DETACH PARTITION orders_2022;
PostgreSQL
ALTER TABLE orders DETACH PARTITION orders_2022;
Attempts:
2 left
💡 Hint
Detaching a partition removes it from the parent but keeps the data intact.
✗ Incorrect
Detaching a partition removes the child table from the partitioned table but does not delete its data. It becomes a normal table.
📝 Syntax
advanced2:00remaining
Identify the syntax error in attaching a partition
Which option contains a syntax error when trying to attach a partition
log_2023 to a partitioned table logs for the year 2023?Attempts:
2 left
💡 Hint
Check the syntax for specifying range values in the ATTACH PARTITION command.
✗ Incorrect
The FROM and TO values must be enclosed in parentheses. Option B misses the parentheses causing a syntax error.
🔧 Debug
advanced2:00remaining
Why does attaching a partition fail?
You try to attach a partition
The command fails with an error about overlapping ranges. What is the most likely cause?
events_2023 to a partitioned table events using:ALTER TABLE events ATTACH PARTITION events_2023 FOR VALUES FROM ('2023-01-01') TO ('2024-01-01');The command fails with an error about overlapping ranges. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check existing partitions and their ranges for conflicts.
✗ Incorrect
Partition ranges cannot overlap. If an existing partition covers any part of the specified range, attaching fails.
🧠 Conceptual
expert2:00remaining
Effect of detaching a partition on indexes
After detaching a partition
archive_2020 from a partitioned table archive, what happens to the indexes defined on the partitioned table?Attempts:
2 left
💡 Hint
Consider how indexes are managed on partitions versus standalone tables.
✗ Incorrect
Partitions have their own indexes. Detaching makes the partition a standalone table, so its indexes remain intact.