May 2017
Beginner
416 pages
10h 37m
English
Before digging deeper into the advantages of partitioning, I want to show how partitions can be created. The entire thing starts with a parent table:
test=# CREATE TABLE t_data (id serial, t date, payload text); CREATE TABLE
In this example, the parent table has three columns. The date column will be used for partitioning but more on that a bit later.
Now that the parent table is in place, the child tables can be created. This is how it works:
test=# CREATE TABLE t_data_2016 () INHERITS (t_data); CREATE TABLE test=# \d t_data_2016 Table "public.t_data_2016" Column | Type | Modifiers ---------+---------+----------------------------------------------------- id | integer | not null default nextval('t_data_id_seq'::regclass) ...Read now
Unlock full access