Bird
0
0

You try to create a partitioned table with the command: CREATE TABLE sales PARTITION BY RANGE (sale_date); but get an error. What is a likely cause?

medium📝 Debug Q6 of 15
PostgreSQL - Table Partitioning
You try to create a partitioned table with the command: CREATE TABLE sales PARTITION BY RANGE (sale_date); but get an error. What is a likely cause?
AThe partition key column must be NOT NULL
BThe table must have a primary key before partitioning
CNo partitions have been defined yet
DPartitioning requires a UNIQUE constraint on the key
Step-by-Step Solution
Solution:
  1. Step 1: Recall partition key requirements

    Partition key columns must be NOT NULL to ensure correct partitioning.
  2. Step 2: Identify cause of error

    If sale_date allows NULL, PostgreSQL rejects partitioning.
  3. Final Answer:

    The partition key column must be NOT NULL -> Option A
  4. Quick Check:

    Partition key NOT NULL = Required [OK]
Quick Trick: Partition keys must be NOT NULL columns [OK]
Common Mistakes:
  • Thinking primary key is mandatory for partitioning
  • Believing partitions must exist before table creation
  • Assuming UNIQUE constraint is required on partition key

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes