0
0
PostgreSQLquery~10 mins

Attaching and detaching partitions 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 attach a partition named 'sales_2023' to the parent table 'sales'.

PostgreSQL
ALTER TABLE sales [1] PARTITION sales_2023 FOR VALUES FROM ('2023-01-01') TO ('2024-01-01');
Drag options to blanks, or click blank then click option'
ADETACH
BADD
CATTACH
DCREATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using DETACH instead of ATTACH.
Using CREATE instead of ATTACH.
Forgetting the PARTITION keyword.
2fill in blank
medium

Complete the code to detach the partition named 'sales_2022' from the parent table 'sales'.

PostgreSQL
ALTER TABLE sales [1] PARTITION sales_2022;
Drag options to blanks, or click blank then click option'
AATTACH
BDETACH
CREMOVE
DDROP
Attempts:
3 left
💡 Hint
Common Mistakes
Using ATTACH instead of DETACH.
Using DROP which deletes the partition table.
Using REMOVE which is not a valid keyword here.
3fill in blank
hard

Fix the error in the code to correctly attach the partition 'orders_2024' to 'orders' table.

PostgreSQL
ALTER TABLE orders [1] PARTITION orders_2024 FOR VALUES FROM ('2024-01-01') TO ('2025-01-01');
Drag options to blanks, or click blank then click option'
AATTACH
BDETACH
CADD
DCREATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using ADD or CREATE instead of ATTACH.
Confusing DETACH with ATTACH.
4fill in blank
hard

Fill in the blank to detach partition 'archive_2020' from 'archive' table and keep the data intact.

PostgreSQL
ALTER TABLE archive [1] PARTITION archive_2020;
Drag options to blanks, or click blank then click option'
ADROP
BREMOVE
CKEEP
DDETACH
Attempts:
3 left
💡 Hint
Common Mistakes
Using DROP which deletes the partition table and data.
Using REMOVE which is not a valid keyword here.
5fill in blank
hard

Fill all three blanks to attach partition 'logs_2023' to 'logs' table with correct value range.

PostgreSQL
ALTER TABLE logs [1] PARTITION logs_2023 FOR VALUES FROM ([2]) TO ([3]);
Drag options to blanks, or click blank then click option'
ADETACH
B'2023-01-01'
C'2024-01-01'
DATTACH
Attempts:
3 left
💡 Hint
Common Mistakes
Using DETACH instead of ATTACH.
Not quoting the date values.
Swapping the FROM and TO values.