Creating horizontal partitions
In the video, you also learned about horizontal partitioning.
The example of horizontal partitioning showed the syntax necessary to create horizontal partitions in PostgreSQL. If you need a reminder, you can have a look at the slides.
In this exercise, however, you'll be using a list partition instead of a range partition. For list partitions, you form partitions by checking whether the partition key is in a list of values or not.
To do this, we partition by LIST
instead of RANGE
. When creating the partitions, you should check if the values are IN
a list of values.
We'll be using the following columns in this exercise:
film_id
: the unique identifier of the filmtitle
: the title of the filmrelease_year
: the year it's released
This exercise is part of the course
Database Design
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Create a new table called film_partitioned
CREATE TABLE film_partitioned (
film_id INT,
title TEXT NOT NULL,
release_year TEXT
)
___ ___ ___ (___);