Anda dapat menggunakan ekspresi di partition by
klausa, misalnya:
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');
Hasil:
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)
Jika partisi tidak peka huruf besar/kecil, Anda dapat menggunakan
create table my_table(name text)
partition by list (lower(left(name, 1)));
Baca di dokumentasi: