country
country
pg_country : Country data type, ISO 3166-1
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3600 | country | pg_country | 0.0.3 | TYPE | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | l10n_table_dependent_extension pg_xenophile currency geoip icu_ext prefix semver unit |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.0.3 | 18 17 16 15 14 | pg_country | - |
| RPM | PIGSTY | 0.0.3 | 18 17 16 15 14 | pg_country_$v | - |
| DEB | PIGSTY | 0.0.3 | 18 17 16 15 14 | postgresql-$v-pg-country | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
el8.aarch64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
el9.x86_64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
el9.aarch64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
el10.x86_64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
el10.aarch64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
d12.x86_64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
d12.aarch64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
d13.x86_64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
d13.aarch64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
u22.x86_64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
u22.aarch64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
u24.x86_64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
u24.aarch64 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 | PIGSTY 0.0.3 |
Source
pig build pkg pg_country; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_country; # install via package name, for the active PG version
pig install country; # install by extension name, for the current active PG version
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
pig install country -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION country;Usage
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.
Last updated on