PostgreSQL Features
pgtofu provides comprehensive support for PostgreSQL schema objects. This page documents all supported features and their usage.Tables
Basic Tables
All Column Types
pgtofu supports all PostgreSQL built-in types:Numeric Types
Numeric Types
| Type | Aliases | Description |
|---|---|---|
smallint | int2 | 2-byte integer |
integer | int, int4 | 4-byte integer |
bigint | int8 | 8-byte integer |
numeric(p,s) | decimal | Arbitrary precision |
real | float4 | 4-byte floating point |
double precision | float8 | 8-byte floating point |
smallserial | serial2 | Auto-increment 2-byte |
serial | serial4 | Auto-increment 4-byte |
bigserial | serial8 | Auto-increment 8-byte |
Character Types
Character Types
| Type | Description |
|---|---|
character varying(n) | Variable-length with limit |
varchar(n) | Alias for character varying |
character(n) | Fixed-length, blank padded |
char(n) | Alias for character |
text | Variable unlimited length |
Date/Time Types
Date/Time Types
| Type | Description |
|---|---|
timestamp | Date and time (no TZ) |
timestamp with time zone | Date and time with TZ |
timestamptz | Alias for timestamp with TZ |
date | Date only |
time | Time only (no TZ) |
time with time zone | Time with TZ |
interval | Time span |
Boolean & Binary
Boolean & Binary
| Type | Description |
|---|---|
boolean | True/false |
bool | Alias for boolean |
bytea | Binary data |
UUID & JSON
UUID & JSON
| Type | Description |
|---|---|
uuid | UUID (requires uuid-ossp) |
json | JSON text |
jsonb | Binary JSON (indexable) |
Network & Geometric
Network & Geometric
| Type | Description |
|---|---|
inet | IPv4 or IPv6 host |
cidr | IPv4 or IPv6 network |
macaddr | MAC address |
point, line, box | Geometric types |
circle, path, polygon | More geometric |
Arrays
Arrays
| Type | Description |
|---|---|
integer[] | 1D integer array |
text[][] | 2D text array |
Any type with [] | Array of that type |
Identity Columns
Modern alternative to SERIAL (PostgreSQL 10+):Generated Columns
Computed columns (PostgreSQL 12+):Constraints
Primary Key
Foreign Keys
ON DELETE CASCADE- Delete dependent rowsON DELETE SET NULL- Set FK to NULLON DELETE SET DEFAULT- Set FK to defaultON DELETE RESTRICT- Prevent deletion (default)ON DELETE NO ACTION- Similar to RESTRICT
Unique Constraints
Check Constraints
Exclusion Constraints
Deferrable Constraints
Indexes
Basic Indexes
Index Types
Partial Indexes
Covering Indexes (PostgreSQL 11+)
Expression Indexes
Views
Regular Views
Materialized Views
Functions
PL/pgSQL Functions
SQL Functions
Function Attributes
Triggers
Row-Level Triggers
Statement-Level Triggers
Conditional Triggers
Custom Types
Enum Types
Composite Types
Domain Types
Extensions
Sequences
Comments
See Also
- TimescaleDB Features - Time-series extensions
- Partitioning - Table partitioning
- Declarative Migrations - Schema file format