base62

Base62 extension for PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
pg_base620.0.1FUNCMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
4810base62NoYesNoYesNoNo-
Relatedbase36 pg_base58 pg_polyline uri pg_curl url_encode pg_rewrite sepgsql

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.0.11817161514pg_base62-
RPMPIGSTY0.0.11817161514pg_base62_$v-
DEBPIGSTY0.0.11817161514postgresql-$v-base62-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
u22.x86_64
u22.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
u24.x86_64
u24.aarch64
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1
PIGSTY 0.0.1

Build

You can build the RPM / DEB packages for pg_base62 using pig build:

pig build pkg pg_base62         # build RPM / DEB packages

Install

You can install pg_base62 directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install pg_base62;          # Install for current active PG version
pig ext install -y pg_base62 -v 18  # PG 18
pig ext install -y pg_base62 -v 17  # PG 17
pig ext install -y pg_base62 -v 16  # PG 16
pig ext install -y pg_base62 -v 15  # PG 15
pig ext install -y pg_base62 -v 14  # PG 14
dnf install -y pg_base62_18       # PG 18
dnf install -y pg_base62_17       # PG 17
dnf install -y pg_base62_16       # PG 16
dnf install -y pg_base62_15       # PG 15
dnf install -y pg_base62_14       # PG 14
apt install -y postgresql-18-base62   # PG 18
apt install -y postgresql-17-base62   # PG 17
apt install -y postgresql-16-base62   # PG 16
apt install -y postgresql-15-base62   # PG 15
apt install -y postgresql-14-base62   # PG 14

Create Extension:

CREATE EXTENSION base62;

Usage

base62: base62 encoding/decoding data types for PostgreSQL

Provides data types for encoding and decoding values using the base62 scheme (0-9, A-Z, a-z).

CREATE EXTENSION base62;

Types

TypeStorageMax String LengthMax Numeric Value
base624 bytes (int)6 characters2,147,483,647
bigbase628 bytes (bigint)11 characters9,223,372,036,854,775,807
hugebase6216 bytes20 characters(bytea conversion)

Examples

-- Encode/decode base62
SELECT 2147483647::base62;          -- '2LKcb1'
SELECT '2LKcb1'::base62::int;      -- 2147483647

-- Bigbase62 for larger values
SELECT 9223372036854775807::bigbase62;           -- 'AzL8n0Y58m7'
SELECT 'AzL8n0Y58m7'::bigbase62::bigint;        -- 9223372036854775807

-- Hugebase62 with bytea conversion
SELECT 'AzL8n0Y58m7AzL8n0Y58'::hugebase62;
SELECT 'AzL8n0Y58m7AzL8n0Y58'::hugebase62::bytea;
SELECT '\x960c06065a6ed8ffff1e7149f40b1800'::bytea::hugebase62;

-- Note: base62 is case-sensitive
SELECT '2lkcb'::base62::int;   -- 40933305
SELECT '2LKCB'::base62::int;   -- 34635195

Last Modified 2026-03-12: add pg extension catalog (95749bf)