Skip to content

pg_money

Exact currency-aware monetary types, arithmetic, and allocation

pg_money · Exact currency-aware monetary types, arithmetic, and allocation

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3690pg_moneypg_money0.3.0TYPEMITRust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
Relationships
See Alsocurrency financial pg_rational pgmp
Currency metadata is built in; the currency extension is related, not required.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.3.019 18 17 16 15pg_money-
RPMPIGSTY0.3.019 18 17 16 15pg_money_$v-
DEBPIGSTY0.3.019 18 17 16 15postgresql-$v-pg-money-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
el8.aarch64N/APIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
el9.x86_64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
el9.aarch64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
el10.x86_64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
el10.aarch64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
d12.x86_64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
d12.aarch64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
d13.x86_64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
d13.aarch64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
u22.x86_64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
u22.aarch64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
u24.x86_64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
u24.aarch64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
u26.x86_64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
u26.aarch64PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
PackageVersionOSORGSIZEFile URL
pg_money_190.3.0el9.x86_64pigsty1.2 MiBpg_money_19-0.3.0-2PGSTY.el9.x86_64.rpm
pg_money_190.3.0el9.aarch64pigsty1.1 MiBpg_money_19-0.3.0-2PGSTY.el9.aarch64.rpm
pg_money_190.3.0el10.x86_64pigsty1.2 MiBpg_money_19-0.3.0-2PGSTY.el10.x86_64.rpm
pg_money_190.3.0el10.aarch64pigsty1.2 MiBpg_money_19-0.3.0-2PGSTY.el10.aarch64.rpm
postgresql-19-pg-money0.3.0d12.x86_64pigsty844.7 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~bookworm_amd64.deb
postgresql-19-pg-money0.3.0d12.aarch64pigsty732.9 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~bookworm_arm64.deb
postgresql-19-pg-money0.3.0d13.x86_64pigsty845.3 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~trixie_amd64.deb
postgresql-19-pg-money0.3.0d13.aarch64pigsty733.0 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~trixie_arm64.deb
postgresql-19-pg-money0.3.0u22.x86_64pigsty940.5 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~jammy_amd64.deb
postgresql-19-pg-money0.3.0u22.aarch64pigsty867.4 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~jammy_arm64.deb
postgresql-19-pg-money0.3.0u24.x86_64pigsty929.1 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~noble_amd64.deb
postgresql-19-pg-money0.3.0u24.aarch64pigsty863.0 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~noble_arm64.deb
postgresql-19-pg-money0.3.0u26.x86_64pigsty918.0 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~resolute_amd64.deb
postgresql-19-pg-money0.3.0u26.aarch64pigsty859.0 KiBpostgresql-19-pg-money_0.3.0-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_money_180.3.0el8.x86_64pigsty1017.7 KiBpg_money_18-0.3.0-1PGSTY.el8.x86_64.rpm
pg_money_180.3.0el8.aarch64pigsty970.7 KiBpg_money_18-0.3.0-1PGSTY.el8.aarch64.rpm
pg_money_180.3.0el9.x86_64pigsty1.2 MiBpg_money_18-0.3.0-2PGSTY.el9.x86_64.rpm
pg_money_180.3.0el9.aarch64pigsty1.1 MiBpg_money_18-0.3.0-2PGSTY.el9.aarch64.rpm
pg_money_180.3.0el10.x86_64pigsty1.2 MiBpg_money_18-0.3.0-2PGSTY.el10.x86_64.rpm
pg_money_180.3.0el10.aarch64pigsty1.1 MiBpg_money_18-0.3.0-2PGSTY.el10.aarch64.rpm
postgresql-18-pg-money0.3.0d12.x86_64pigsty841.7 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~bookworm_amd64.deb
postgresql-18-pg-money0.3.0d12.aarch64pigsty732.0 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~bookworm_arm64.deb
postgresql-18-pg-money0.3.0d13.x86_64pigsty843.5 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~trixie_amd64.deb
postgresql-18-pg-money0.3.0d13.aarch64pigsty732.0 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~trixie_arm64.deb
postgresql-18-pg-money0.3.0u22.x86_64pigsty939.9 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~jammy_amd64.deb
postgresql-18-pg-money0.3.0u22.aarch64pigsty865.4 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~jammy_arm64.deb
postgresql-18-pg-money0.3.0u24.x86_64pigsty926.0 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~noble_amd64.deb
postgresql-18-pg-money0.3.0u24.aarch64pigsty860.2 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~noble_arm64.deb
postgresql-18-pg-money0.3.0u26.x86_64pigsty914.1 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~resolute_amd64.deb
postgresql-18-pg-money0.3.0u26.aarch64pigsty857.8 KiBpostgresql-18-pg-money_0.3.0-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_money_170.3.0el8.x86_64pigsty1014.9 KiBpg_money_17-0.3.0-1PGSTY.el8.x86_64.rpm
pg_money_170.3.0el8.aarch64pigsty966.9 KiBpg_money_17-0.3.0-1PGSTY.el8.aarch64.rpm
pg_money_170.3.0el9.x86_64pigsty1.2 MiBpg_money_17-0.3.0-2PGSTY.el9.x86_64.rpm
pg_money_170.3.0el9.aarch64pigsty1.1 MiBpg_money_17-0.3.0-2PGSTY.el9.aarch64.rpm
pg_money_170.3.0el10.x86_64pigsty1.2 MiBpg_money_17-0.3.0-2PGSTY.el10.x86_64.rpm
pg_money_170.3.0el10.aarch64pigsty1.1 MiBpg_money_17-0.3.0-2PGSTY.el10.aarch64.rpm
postgresql-17-pg-money0.3.0d12.x86_64pigsty839.4 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~bookworm_amd64.deb
postgresql-17-pg-money0.3.0d12.aarch64pigsty729.7 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~bookworm_arm64.deb
postgresql-17-pg-money0.3.0d13.x86_64pigsty839.4 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~trixie_amd64.deb
postgresql-17-pg-money0.3.0d13.aarch64pigsty729.8 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~trixie_arm64.deb
postgresql-17-pg-money0.3.0u22.x86_64pigsty937.5 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~jammy_amd64.deb
postgresql-17-pg-money0.3.0u22.aarch64pigsty862.9 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~jammy_arm64.deb
postgresql-17-pg-money0.3.0u24.x86_64pigsty922.2 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~noble_amd64.deb
postgresql-17-pg-money0.3.0u24.aarch64pigsty858.8 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~noble_arm64.deb
postgresql-17-pg-money0.3.0u26.x86_64pigsty911.1 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~resolute_amd64.deb
postgresql-17-pg-money0.3.0u26.aarch64pigsty855.6 KiBpostgresql-17-pg-money_0.3.0-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_money_160.3.0el8.x86_64pigsty1013.7 KiBpg_money_16-0.3.0-1PGSTY.el8.x86_64.rpm
pg_money_160.3.0el8.aarch64pigsty965.8 KiBpg_money_16-0.3.0-1PGSTY.el8.aarch64.rpm
pg_money_160.3.0el9.x86_64pigsty1.2 MiBpg_money_16-0.3.0-2PGSTY.el9.x86_64.rpm
pg_money_160.3.0el9.aarch64pigsty1.1 MiBpg_money_16-0.3.0-2PGSTY.el9.aarch64.rpm
pg_money_160.3.0el10.x86_64pigsty1.2 MiBpg_money_16-0.3.0-2PGSTY.el10.x86_64.rpm
pg_money_160.3.0el10.aarch64pigsty1.1 MiBpg_money_16-0.3.0-2PGSTY.el10.aarch64.rpm
postgresql-16-pg-money0.3.0d12.x86_64pigsty838.1 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~bookworm_amd64.deb
postgresql-16-pg-money0.3.0d12.aarch64pigsty728.7 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~bookworm_arm64.deb
postgresql-16-pg-money0.3.0d13.x86_64pigsty839.1 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~trixie_amd64.deb
postgresql-16-pg-money0.3.0d13.aarch64pigsty730.4 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~trixie_arm64.deb
postgresql-16-pg-money0.3.0u22.x86_64pigsty935.3 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~jammy_amd64.deb
postgresql-16-pg-money0.3.0u22.aarch64pigsty863.2 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~jammy_arm64.deb
postgresql-16-pg-money0.3.0u24.x86_64pigsty921.9 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~noble_amd64.deb
postgresql-16-pg-money0.3.0u24.aarch64pigsty856.0 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~noble_arm64.deb
postgresql-16-pg-money0.3.0u26.x86_64pigsty912.6 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~resolute_amd64.deb
postgresql-16-pg-money0.3.0u26.aarch64pigsty855.1 KiBpostgresql-16-pg-money_0.3.0-2PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_money_150.3.0el8.x86_64pigsty1005.9 KiBpg_money_15-0.3.0-1PGSTY.el8.x86_64.rpm
pg_money_150.3.0el8.aarch64pigsty955.8 KiBpg_money_15-0.3.0-1PGSTY.el8.aarch64.rpm
pg_money_150.3.0el9.x86_64pigsty1.2 MiBpg_money_15-0.3.0-2PGSTY.el9.x86_64.rpm
pg_money_150.3.0el9.aarch64pigsty1.1 MiBpg_money_15-0.3.0-2PGSTY.el9.aarch64.rpm
pg_money_150.3.0el10.x86_64pigsty1.2 MiBpg_money_15-0.3.0-2PGSTY.el10.x86_64.rpm
pg_money_150.3.0el10.aarch64pigsty1.1 MiBpg_money_15-0.3.0-2PGSTY.el10.aarch64.rpm
postgresql-15-pg-money0.3.0d12.x86_64pigsty836.8 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~bookworm_amd64.deb
postgresql-15-pg-money0.3.0d12.aarch64pigsty726.0 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~bookworm_arm64.deb
postgresql-15-pg-money0.3.0d13.x86_64pigsty836.4 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~trixie_amd64.deb
postgresql-15-pg-money0.3.0d13.aarch64pigsty727.1 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~trixie_arm64.deb
postgresql-15-pg-money0.3.0u22.x86_64pigsty932.0 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~jammy_amd64.deb
postgresql-15-pg-money0.3.0u22.aarch64pigsty859.9 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~jammy_arm64.deb
postgresql-15-pg-money0.3.0u24.x86_64pigsty912.1 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~noble_amd64.deb
postgresql-15-pg-money0.3.0u24.aarch64pigsty853.0 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~noble_arm64.deb
postgresql-15-pg-money0.3.0u26.x86_64pigsty908.8 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~resolute_amd64.deb
postgresql-15-pg-money0.3.0u26.aarch64pigsty849.7 KiBpostgresql-15-pg-money_0.3.0-2PGSTY~resolute_arm64.deb

Source

pig build pkg pg_money;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_money;		# install by package name

pig install pg_money -v 19;   # install for PG 19
pig install pg_money -v 18;   # install for PG 18
pig install pg_money -v 17;   # install for PG 17
pig install pg_money -v 16;   # install for PG 16
pig install pg_money -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_money;

Usage

Sources:

pg_money provides exact currency-aware amounts, arithmetic, rounding, and allocation on PostgreSQL 14–18. Its types are distinct from the locale-sensitive built-in money type.

Core Workflow

CREATE EXTENSION pg_money;
CREATE TABLE invoices (id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
                       total money_with_currency NOT NULL);
INSERT INTO invoices(total) VALUES ('USD 19.95'), (money_make(5.25, 'USD'));
SELECT sum(total), avg(total), money_format(sum(total)) FROM invoices;
SELECT money_split('USD 10.00', 3);
SELECT money_exchange('USD 100', 'EUR', 0.85);

Objects and Semantics

money_with_currency stores a currency with an exact decimal amount; money_minor works with minor-unit amounts. money_make, money_from_minor, and money_minor_make construct values. money_round accepts an explicit rounding mode, and money_split allocates residual units while conserving the total.

Arithmetic and aggregation reject incompatible currencies instead of converting implicitly. Exchange rates are supplied explicitly or read from an application-owned table with money_exchange_at; the extension fetches no market rates. Check rounding and amount bounds at application boundaries.

Operation

The 0.3.0 control file requires superuser installation and allows relocation. No preload is required. Treat exchange-rate tables and mutation privileges separately from read-only arithmetic; caller-supplied SQL data does not establish the correctness or freshness of a rate.

Table reader