base62
Base62 extension for PostgreSQL
Repository
adjust/pg-base62
https://github.com/adjust/pg-base62
Source
pg-base62-0.0.1.tar.gz
pg-base62-0.0.1.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_base62 | 0.0.1 | FUNC | MIT | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4810 | base62 | No | Yes | No | Yes | No | No | - |
| Related | base36 pg_base58 pg_polyline uri pg_curl url_encode pg_rewrite sepgsql |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.0.1 | 1817161514 | pg_base62 | - |
| RPM | PIGSTY | 0.0.1 | 1817161514 | pg_base62_$v | - |
| DEB | PIGSTY | 0.0.1 | 1817161514 | postgresql-$v-base62 | - |
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
Provides data types for encoding and decoding values using the base62 scheme (0-9, A-Z, a-z).
CREATE EXTENSION base62;
Types
| Type | Storage | Max String Length | Max Numeric Value |
|---|---|---|---|
base62 | 4 bytes (int) | 6 characters | 2,147,483,647 |
bigbase62 | 8 bytes (bigint) | 11 characters | 9,223,372,036,854,775,807 |
hugebase62 | 16 bytes | 20 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
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.