Complete the code to create a partitioned table by range on the column 'created_date'.
CREATE TABLE orders ( order_id SERIAL, created_date DATE NOT NULL, amount NUMERIC(10, 2) NOT NULL, PRIMARY KEY (created_date, order_id) ) PARTITION BY [1] (created_date);
The PARTITION BY RANGE clause creates partitions based on ranges of values in the specified column.
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 FROM (MINVALUE) [1] ('2023-01-01');
The FOR VALUES FROM (MINVALUE) TO clause defines the upper bound for the range partition.
Fix the error in the partition creation by choosing the correct keyword for the range start.
CREATE TABLE orders_2023 PARTITION OF orders FOR VALUES [1] ('2023-01-01') TO ('2024-01-01');
The FROM keyword specifies the lower bound of the range partition.
Fill both blanks to create a list partition for the 'orders' table for specific regions.
CREATE TABLE orders ( order_id SERIAL, region TEXT NOT NULL, amount NUMERIC(10, 2) NOT NULL, PRIMARY KEY (region, order_id) ) PARTITION BY [1] (region); CREATE TABLE orders_us PARTITION OF orders FOR VALUES [2] ('US', 'Canada');
PARTITION BY LIST is used to partition by specific values, and FOR VALUES IN specifies those values.
Fill all three blanks to create a hash partitioned table with 4 partitions.
CREATE TABLE users ( user_id SERIAL PRIMARY KEY, username TEXT NOT NULL ) PARTITION BY [1] (user_id); CREATE TABLE users_part_1 PARTITION OF users FOR VALUES WITH ([2] 4, [3] 0);
PARTITION BY HASH partitions data by hashing the column. The MODULUS defines the number of partitions, and REMAINDER specifies the partition number.