Developmentversion 1.0
tablefunc
Crosstab and other table functions.
What it is for
tablefunc provides crosstab for pivoting rows into columns, connectby for walking parent-child tables, and normal_rand for generating normally distributed test data.
Enable it
create extension if not exists tablefunc with schema extensions;Example
select * from crosstab(
$$select region, quarter, sum(amount) from sales group by 1, 2 order by 1, 2$$,
$$select unnest(array['Q1', 'Q2', 'Q3', 'Q4'])$$
) as pivot(region text, q1 numeric, q2 numeric, q3 numeric, q4 numeric);Questions
How do I enable tablefunc?
Run create extension if not exists tablefunc with schema extensions; in the SQL editor, or switch it on from the Extensions page in the console. You do not need superuser access.
Which version of tablefunc is installed?
1.0, on Postgres 17.6, as read from the running engine on 2026-10-08. Check yours with: select extversion from pg_extension where extname = 'tablefunc';
Upstream project: www.postgresql.org/docs/17/tablefunc.html
More development extensions
- plpgsql_check Lint PL/pgSQL functions before they run.