Du kan bruge et udtryk i partition by
klausul, f.eks.:
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');
Resultater:
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)
Hvis partitioneringen skulle være ufølsom over for store og små bogstaver, kan du bruge
create table my_table(name text)
partition by list (lower(left(name, 1)));
Læs i dokumentationen: