Complete the code to create a hash partitioned table on the column 'user_id'.
CREATE TABLE users (
user_id INT,
name TEXT
) PARTITION BY [1] (user_id);The hash partitioning method distributes rows based on a hash of the partition key, here 'user_id'.
Complete the code to create a hash partition with 4 partitions.
CREATE TABLE users_part_[1] PARTITION OF users FOR VALUES WITH (MODULUS 4, REMAINDER [1]);
Partitions are created with a remainder value from 0 to modulus-1. Here, remainder 0 is the first partition.
Fix the error in the partition creation statement to correctly specify the remainder.
CREATE TABLE users_part_[1] PARTITION OF users FOR VALUES WITH (MODULUS 4, REMAINDER [1]);
The remainder must be less than the modulus. Since modulus is 4, remainder 3 is the highest valid value.
Fill both blanks to create two hash partitions with modulus 3 and remainders 0 and 1.
CREATE TABLE users_part_[1] PARTITION OF users FOR VALUES WITH (MODULUS [2], REMAINDER 0); CREATE TABLE users_part_1 PARTITION OF users FOR VALUES WITH (MODULUS [2], REMAINDER 1);
The partition names use remainders 0 and 1, and modulus is 3 for both partitions.
Fill all three blanks to create a hash partitioned table and one partition with modulus 5 and remainder 2.
CREATE TABLE orders ( order_id INT, customer_id INT ) PARTITION BY [1] (customer_id); CREATE TABLE orders_part_[2] PARTITION OF orders FOR VALUES WITH (MODULUS [3], REMAINDER 2);
The table is hash partitioned on 'customer_id'. The partition name uses remainder 2, and modulus is 5.