Bird
0
0

You have this partitioned table:

medium📝 Debug Q14 of 15
PostgreSQL - Table Partitioning
You have this partitioned table:
CREATE TABLE logs (id SERIAL, log_date DATE) PARTITION BY RANGE (log_date);
CREATE TABLE logs_2023 PARTITION OF logs FOR VALUES FROM ('2023-01-01') TO ('2024-01-01');

Which error will occur if you run this?
INSERT INTO logs (log_date) VALUES ('2022-12-31');
AERROR: syntax error near VALUES
BERROR: no partition found for row
CThe row is inserted into logs_2023 partition
DThe row is inserted into a default partition automatically
Step-by-Step Solution
Solution:
  1. Step 1: Check partition ranges

    logs_2023 covers dates from 2023-01-01 to 2024-01-01 only.
  2. Step 2: Insert date outside partition range

    2022-12-31 is before 2023-01-01, so no matching partition exists.
  3. Final Answer:

    ERROR: no partition found for row -> Option B
  4. Quick Check:

    Insert outside range = no partition error [OK]
Quick Trick: Insert date must fit partition range or error occurs [OK]
Common Mistakes:
  • Expecting automatic default partition
  • Thinking syntax error occurs
  • Assuming row goes to nearest partition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes