Bird
0
0

Which of the following is the correct syntax to create a range partitioned table in PostgreSQL?

easy📝 Syntax Q12 of 15
PostgreSQL - Table Partitioning
Which of the following is the correct syntax to create a range partitioned table in PostgreSQL?
ACREATE TABLE sales (id INT, sale_date DATE) PARTITION BY LIST (sale_date);
BCREATE TABLE sales PARTITION BY RANGE (sale_date) (id INT, sale_date DATE);
CCREATE TABLE sales (id INT, sale_date DATE) PARTITION ON RANGE sale_date;
DCREATE TABLE sales (id INT, sale_date DATE) PARTITION BY RANGE (sale_date);
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct partition syntax

    PostgreSQL uses PARTITION BY RANGE (column) after table columns.
  2. Step 2: Check each option

    CREATE TABLE sales (id INT, sale_date DATE) PARTITION BY RANGE (sale_date); matches syntax: columns first, then PARTITION BY RANGE.
  3. Final Answer:

    CREATE TABLE sales (id INT, sale_date DATE) PARTITION BY RANGE (sale_date); -> Option D
  4. Quick Check:

    PARTITION BY RANGE after columns = correct syntax [OK]
Quick Trick: Partition type follows column definitions in CREATE TABLE [OK]
Common Mistakes:
  • Placing PARTITION BY before columns
  • Using PARTITION ON instead of PARTITION BY
  • Confusing RANGE with LIST partition type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes