Bird
0
0

You have a table partitioned by month and sub-partitioned by product category. You want to add a new sub-partition for a new category 'Gadgets' under the '2024-01' partition. Which command is correct?

hard📝 Application Q9 of 15
PostgreSQL - Table Partitioning
You have a table partitioned by month and sub-partitioned by product category. You want to add a new sub-partition for a new category 'Gadgets' under the '2024-01' partition. Which command is correct?
ACREATE TABLE sales_2024_01_gadgets PARTITION OF sales_2024_01 FOR VALUES IN ('Gadgets');
BALTER TABLE sales_2024_01 ADD PARTITION FOR VALUES IN ('Gadgets');
CCREATE SUBPARTITION sales_2024_01_gadgets FOR VALUES IN ('Gadgets');
DALTER TABLE sales ADD SUBPARTITION sales_2024_01_gadgets FOR VALUES IN ('Gadgets');"
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct syntax for adding sub-partition

    New sub-partition is created as a table partition of the parent partition.
  2. Step 2: Check options

    CREATE TABLE sales_2024_01_gadgets PARTITION OF sales_2024_01 FOR VALUES IN ('Gadgets'); uses CREATE TABLE ... PARTITION OF with FOR VALUES IN, which is correct.
  3. Final Answer:

    CREATE TABLE sales_2024_01_gadgets PARTITION OF sales_2024_01 FOR VALUES IN ('Gadgets'); -> Option A
  4. Quick Check:

    Create sub-partition as table partition of parent [OK]
Quick Trick: Create sub-partition as table partition of parent partition [OK]
Common Mistakes:
  • Using ALTER TABLE ADD PARTITION on sub-partitions
  • Using non-existent CREATE SUBPARTITION command
  • Trying to add sub-partition directly to main table

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes