Skip to content

iban

International Bank Account Number type with format and checksum validation

iban · International Bank Account Number type with format and checksum validation

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3685ibaniban1.2.0TYPEGPL-3.0-or-laterC++
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
Relationships
See Alsocurrency pg_money
SQL version 1.2.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.2.019 18 17 16 15iban-
RPMPIGSTY1.2.019 18 17 16 15iban_$v-
DEBPIGSTY1.2.019 18 17 16 15postgresql-$v-iban-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
el8.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
el9.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
el9.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
el10.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
el10.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
d12.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
d12.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
d13.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
d13.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
u22.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
u22.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
u24.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
u24.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
u26.x86_64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0
u26.aarch64N/APIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0PIGSTY 1.2.0

Source

pig build pkg iban;		# 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 iban;		# install by package name

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

Create this extension with:

CREATE EXTENSION iban;

Usage

Sources:

iban SQL 1.2, distributed as upstream 1.2.0, adds a validated International Bank Account Number type and iban_validate(text). Country-specific BBAN structure and a mod-97 checksum reject malformed values; successful validation does not prove account existence, ownership or payment-network reachability. Upstream supports PostgreSQL 14–18.

Store and Compare Values

CREATE EXTENSION iban;
CREATE TABLE beneficiaries (
    beneficiary_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    account_iban iban NOT NULL
);
INSERT INTO beneficiaries (account_iban)
VALUES ('gb82 west 1234 5698 7654 32');
SELECT account_iban, iban_validate(account_iban::text)
FROM beneficiaries ORDER BY account_iban;
CREATE INDEX beneficiaries_iban_idx ON beneficiaries (account_iban);

Text input is uppercased and plain spaces are removed, so the stored value in this example is GB82WEST12345698765432. Tabs, newlines and other whitespace are not removed. Input longer than 64 bytes is rejected; error output repeats at most 40 input bytes. Binary input is now validated and normalized by the same rules.

Objects

  • iban_validate(text) returns a validation result without storing a value.
  • iban supports casts to text types and comparison operators. iban_cmp(iban, iban) provides byte-order comparison.
  • Default btree and hash operator classes support ordering, equality, joins, grouping and keys; iban_hash(iban) and iban_hash_extended(iban, bigint) support hash operations.

Upgrade and Validation Boundaries

Install matching files, ensure old-library sessions are replaced, then upgrade SQL and normalize rows stored by older versions:

ALTER EXTENSION iban UPDATE TO '1.2';
UPDATE beneficiaries SET account_iban = account_iban::text::iban;

Review existing values and uniqueness collisions before rewriting production data or creating unique indexes: older rows may retain lowercase or noncanonical representations. Country rules are compiled into the extension and may lag registry changes; verify the countries required by the application against this exact release.

Table reader