Bird
0
0

Which of the following is the correct way to define a table partitioned by department (LIST) and sub-partitioned by joining_year (RANGE) in PostgreSQL?

easy📝 Syntax Q3 of 15
PostgreSQL - Table Partitioning
Which of the following is the correct way to define a table partitioned by department (LIST) and sub-partitioned by joining_year (RANGE) in PostgreSQL?
ACREATE TABLE employees (id INT, department TEXT, joining_year INT) PARTITION BY LIST (joining_year) SUBPARTITION BY RANGE (department);
BCREATE TABLE employees (id INT, department TEXT, joining_year INT) PARTITION BY RANGE (joining_year) SUBPARTITION BY LIST (department);
CCREATE TABLE employees (id INT, department TEXT, joining_year INT) PARTITION BY HASH (department) SUBPARTITION BY LIST (joining_year);
DCREATE TABLE employees (id INT, department TEXT, joining_year INT) PARTITION BY LIST (department) SUBPARTITION BY RANGE (joining_year);
Step-by-Step Solution
Solution:
  1. Step 1: Identify partitioning columns and methods

    The question specifies partitioning by department using LIST and sub-partitioning by joining_year using RANGE.
  2. Step 2: Match syntax

    CREATE TABLE employees (id INT, department TEXT, joining_year INT) PARTITION BY LIST (department) SUBPARTITION BY RANGE (joining_year); correctly uses PARTITION BY LIST (department) and SUBPARTITION BY RANGE (joining_year).
  3. Final Answer:

    CREATE TABLE employees (id INT, department TEXT, joining_year INT) PARTITION BY LIST (department) SUBPARTITION BY RANGE (joining_year); is the correct syntax.
  4. Quick Check:

    Partitioning by LIST then sub-partitioning by RANGE [OK]
Quick Trick: Partition by main key, subpartition by secondary key [OK]
Common Mistakes:
  • Swapping partition and subpartition methods
  • Using unsupported partition types like HASH with subpartition
  • Incorrect column order in partitioning clauses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes