Du kan använda ett uttryck i partition by
klausul, t.ex.:
create table my_table(name text)
partition by list (left(name, 1));
create table my_table_a
partition of my_table
for values in ('a');
create table my_table_b
partition of my_table
for values in ('b');
Resultat:
insert into my_table
values
('abba'), ('alfa'), ('beta');
select 'a' as partition, name from my_table_a
union all
select 'b' as partition, name from my_table_b;
partition | name
-----------+------
a | abba
a | alfa
b | beta
(3 rows)
Om partitioneringen skulle vara skiftlägesokänslig kan du använda
create table my_table(name text)
partition by list (lower(left(name, 1)));
Läs i dokumentationen: