Complete the code to create a partitioned table by range on the column 'created_date'.
CREATE TABLE orders (id SERIAL PRIMARY KEY, created_date DATE, amount NUMERIC) PARTITION BY [1] (created_date);The range partitioning method is used to divide data based on ranges of values, such as dates.
Complete the code to create a partition for the 'orders' table for dates before 2023-01-01.
CREATE TABLE orders_2022 PARTITION OF orders FOR VALUES [1] ('2023-01-01');
The TO keyword defines the upper bound for a range partition.
Fix the error in the partition creation statement by choosing the correct partition method.
CREATE TABLE sales PARTITION BY [1] (region);The list partitioning method is used to divide data by discrete values like regions.
Fill both blanks to create a hash partitioned table with 4 partitions.
CREATE TABLE logs (id SERIAL, event_time TIMESTAMP) PARTITION BY [1] (id); CREATE TABLE logs_part_1 PARTITION OF logs FOR VALUES WITH ([2] 4, REMAINDER 0);
Hash partitioning uses the MODULUS keyword to specify partitions based on hash values.
Fill all three blanks to create a range partition for the 'events' table for dates from 2023-01-01 to 2023-06-30.
CREATE TABLE events (id SERIAL, event_date DATE) PARTITION BY [1] (event_date); CREATE TABLE events_h1_2023 PARTITION OF events FOR VALUES FROM ([2]) TO ([3]);
Range partitioning uses FROM and TO with date values to define partitions.