Skip to content

country

Country data type, ISO 3166-1

pg_country · Country data type, ISO 3166-1

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3660countrypg_country0.0.4TYPEPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.0.419 18 17 16 15pg_country-
RPMPIGSTY0.0.419 18 17 16 15pg_country_$v-
DEBPIGSTY0.0.419 18 17 16 15postgresql-$v-pg-country-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
el8.aarch64N/APIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
el9.x86_64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
el9.aarch64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
el10.x86_64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
el10.aarch64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
d12.x86_64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
d12.aarch64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
d13.x86_64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
d13.aarch64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
u22.x86_64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
u22.aarch64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
u24.x86_64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
u24.aarch64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
u26.x86_64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
u26.aarch64PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4PIGSTY 0.0.4
PackageVersionOSORGSIZEFile URL
pg_country_190.0.4el9.x86_64pigsty48.7 KiBpg_country_19-0.0.4-1PGSTY.el9.x86_64.rpm
pg_country_190.0.4el9.aarch64pigsty49.5 KiBpg_country_19-0.0.4-1PGSTY.el9.aarch64.rpm
pg_country_190.0.4el10.x86_64pigsty48.4 KiBpg_country_19-0.0.4-1PGSTY.el10.x86_64.rpm
pg_country_190.0.4el10.aarch64pigsty49.3 KiBpg_country_19-0.0.4-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-country0.0.4d12.x86_64pigsty47.5 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-country0.0.4d12.aarch64pigsty47.7 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-country0.0.4d13.x86_64pigsty47.1 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~trixie_amd64.deb
postgresql-19-pg-country0.0.4d13.aarch64pigsty48.0 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~trixie_arm64.deb
postgresql-19-pg-country0.0.4u22.x86_64pigsty54.9 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~jammy_amd64.deb
postgresql-19-pg-country0.0.4u22.aarch64pigsty55.9 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~jammy_arm64.deb
postgresql-19-pg-country0.0.4u24.x86_64pigsty51.9 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~noble_amd64.deb
postgresql-19-pg-country0.0.4u24.aarch64pigsty53.2 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~noble_arm64.deb
postgresql-19-pg-country0.0.4u26.x86_64pigsty50.9 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~resolute_amd64.deb
postgresql-19-pg-country0.0.4u26.aarch64pigsty52.0 KiBpostgresql-19-pg-country_0.0.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_country_180.0.4el8.x86_64pigsty50.6 KiBpg_country_18-0.0.4-1PGSTY.el8.x86_64.rpm
pg_country_180.0.4el8.aarch64pigsty49.0 KiBpg_country_18-0.0.4-1PGSTY.el8.aarch64.rpm
pg_country_180.0.4el9.x86_64pigsty48.6 KiBpg_country_18-0.0.4-1PGSTY.el9.x86_64.rpm
pg_country_180.0.4el9.aarch64pigsty49.5 KiBpg_country_18-0.0.4-1PGSTY.el9.aarch64.rpm
pg_country_180.0.4el10.x86_64pigsty48.4 KiBpg_country_18-0.0.4-1PGSTY.el10.x86_64.rpm
pg_country_180.0.4el10.aarch64pigsty49.3 KiBpg_country_18-0.0.4-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-country0.0.4d12.x86_64pigsty47.3 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-country0.0.4d12.aarch64pigsty47.6 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-country0.0.4d13.x86_64pigsty47.1 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~trixie_amd64.deb
postgresql-18-pg-country0.0.4d13.aarch64pigsty48.0 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~trixie_arm64.deb
postgresql-18-pg-country0.0.4u22.x86_64pigsty54.9 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~jammy_amd64.deb
postgresql-18-pg-country0.0.4u22.aarch64pigsty55.9 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~jammy_arm64.deb
postgresql-18-pg-country0.0.4u24.x86_64pigsty51.9 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~noble_amd64.deb
postgresql-18-pg-country0.0.4u24.aarch64pigsty53.2 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~noble_arm64.deb
postgresql-18-pg-country0.0.4u26.x86_64pigsty50.9 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~resolute_amd64.deb
postgresql-18-pg-country0.0.4u26.aarch64pigsty52.0 KiBpostgresql-18-pg-country_0.0.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_country_170.0.4el8.x86_64pigsty50.6 KiBpg_country_17-0.0.4-1PGSTY.el8.x86_64.rpm
pg_country_170.0.4el8.aarch64pigsty48.9 KiBpg_country_17-0.0.4-1PGSTY.el8.aarch64.rpm
pg_country_170.0.4el9.x86_64pigsty48.7 KiBpg_country_17-0.0.4-1PGSTY.el9.x86_64.rpm
pg_country_170.0.4el9.aarch64pigsty49.7 KiBpg_country_17-0.0.4-1PGSTY.el9.aarch64.rpm
pg_country_170.0.4el10.x86_64pigsty48.4 KiBpg_country_17-0.0.4-1PGSTY.el10.x86_64.rpm
pg_country_170.0.4el10.aarch64pigsty49.2 KiBpg_country_17-0.0.4-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-country0.0.4d12.x86_64pigsty47.2 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-country0.0.4d12.aarch64pigsty47.5 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-country0.0.4d13.x86_64pigsty47.2 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~trixie_amd64.deb
postgresql-17-pg-country0.0.4d13.aarch64pigsty48.3 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~trixie_arm64.deb
postgresql-17-pg-country0.0.4u22.x86_64pigsty56.2 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~jammy_amd64.deb
postgresql-17-pg-country0.0.4u22.aarch64pigsty57.2 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~jammy_arm64.deb
postgresql-17-pg-country0.0.4u24.x86_64pigsty51.5 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~noble_amd64.deb
postgresql-17-pg-country0.0.4u24.aarch64pigsty52.8 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~noble_arm64.deb
postgresql-17-pg-country0.0.4u26.x86_64pigsty50.8 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~resolute_amd64.deb
postgresql-17-pg-country0.0.4u26.aarch64pigsty52.0 KiBpostgresql-17-pg-country_0.0.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_country_160.0.4el8.x86_64pigsty50.6 KiBpg_country_16-0.0.4-1PGSTY.el8.x86_64.rpm
pg_country_160.0.4el8.aarch64pigsty48.9 KiBpg_country_16-0.0.4-1PGSTY.el8.aarch64.rpm
pg_country_160.0.4el9.x86_64pigsty48.7 KiBpg_country_16-0.0.4-1PGSTY.el9.x86_64.rpm
pg_country_160.0.4el9.aarch64pigsty49.7 KiBpg_country_16-0.0.4-1PGSTY.el9.aarch64.rpm
pg_country_160.0.4el10.x86_64pigsty48.6 KiBpg_country_16-0.0.4-1PGSTY.el10.x86_64.rpm
pg_country_160.0.4el10.aarch64pigsty49.2 KiBpg_country_16-0.0.4-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-country0.0.4d12.x86_64pigsty47.3 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-country0.0.4d12.aarch64pigsty47.8 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-country0.0.4d13.x86_64pigsty47.1 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~trixie_amd64.deb
postgresql-16-pg-country0.0.4d13.aarch64pigsty48.0 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~trixie_arm64.deb
postgresql-16-pg-country0.0.4u22.x86_64pigsty56.2 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~jammy_amd64.deb
postgresql-16-pg-country0.0.4u22.aarch64pigsty57.2 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~jammy_arm64.deb
postgresql-16-pg-country0.0.4u24.x86_64pigsty51.5 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~noble_amd64.deb
postgresql-16-pg-country0.0.4u24.aarch64pigsty52.8 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~noble_arm64.deb
postgresql-16-pg-country0.0.4u26.x86_64pigsty50.7 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~resolute_amd64.deb
postgresql-16-pg-country0.0.4u26.aarch64pigsty52.0 KiBpostgresql-16-pg-country_0.0.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_country_150.0.4el8.x86_64pigsty50.5 KiBpg_country_15-0.0.4-1PGSTY.el8.x86_64.rpm
pg_country_150.0.4el8.aarch64pigsty48.9 KiBpg_country_15-0.0.4-1PGSTY.el8.aarch64.rpm
pg_country_150.0.4el9.x86_64pigsty48.7 KiBpg_country_15-0.0.4-1PGSTY.el9.x86_64.rpm
pg_country_150.0.4el9.aarch64pigsty49.7 KiBpg_country_15-0.0.4-1PGSTY.el9.aarch64.rpm
pg_country_150.0.4el10.x86_64pigsty48.6 KiBpg_country_15-0.0.4-1PGSTY.el10.x86_64.rpm
pg_country_150.0.4el10.aarch64pigsty49.2 KiBpg_country_15-0.0.4-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-country0.0.4d12.x86_64pigsty47.3 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-country0.0.4d12.aarch64pigsty47.7 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-country0.0.4d13.x86_64pigsty47.0 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~trixie_amd64.deb
postgresql-15-pg-country0.0.4d13.aarch64pigsty48.1 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~trixie_arm64.deb
postgresql-15-pg-country0.0.4u22.x86_64pigsty56.2 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~jammy_amd64.deb
postgresql-15-pg-country0.0.4u22.aarch64pigsty57.2 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~jammy_arm64.deb
postgresql-15-pg-country0.0.4u24.x86_64pigsty51.5 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~noble_amd64.deb
postgresql-15-pg-country0.0.4u24.aarch64pigsty52.7 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~noble_arm64.deb
postgresql-15-pg-country0.0.4u26.x86_64pigsty50.8 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~resolute_amd64.deb
postgresql-15-pg-country0.0.4u26.aarch64pigsty52.1 KiBpostgresql-15-pg-country_0.0.4-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_country;		# 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_country;		# install by package name
pig install country;		# install by extension name

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

Create this extension with:

CREATE EXTENSION country;

Usage

country: ISO 3166-1 alpha-2 country code type

The country extension provides an enumerated data type for ISO 3166-1 alpha-2 country codes with minimal storage overhead.

CREATE EXTENSION country;

CREATE TABLE locations (
    id    serial PRIMARY KEY,
    code  country
);

INSERT INTO locations VALUES (1, 'US'), (2, 'GB'), (3, 'FR');

SELECT * FROM locations ORDER BY code;

Data Type

The country type restricts values to valid ISO 3166-1 alpha-2 codes (two-letter country designations like US, GB, FR, DE, etc.). Invalid codes are rejected on input.

Operators

Standard comparison operators are supported: =, <>, <, >, <=, >=.

Index Support

Both B-tree and hash index operator classes are provided for efficient querying and sorting on country columns.

Table reader