Complete the code to create a partitioned table by category.
CREATE TABLE products (id SERIAL, name TEXT, category TEXT, PRIMARY KEY (id, category)) PARTITION BY [1] (category);The LIST partitioning method is used to partition a table by specific values in a column, such as categories.
Complete the code to create a partition for the 'electronics' category.
CREATE TABLE products_electronics PARTITION OF products FOR VALUES [1] ('electronics');
For LIST partitioning, the IN keyword specifies the list of values for the partition.
Fix the error in the partition creation statement.
CREATE TABLE products_clothing PARTITION OF products FOR VALUES [1] ('clothing', 'apparel');
Multiple values in a LIST partition must be specified with IN and a list of values.
Fill both blanks to query all products in the 'books' or 'magazines' categories.
SELECT * FROM products WHERE category [1] ('books', 'magazines') ORDER BY [2];
The IN keyword filters rows by matching any value in the list. Ordering by name sorts the results alphabetically.
Fill all three blanks to insert a new product into the 'furniture' partition.
INSERT INTO products ([1], [2], [3]) VALUES (DEFAULT, 'Chair', 'furniture');
The columns are id (auto-generated), name, and category. The values match these columns.