PgDesigner

PostgreSQL Sample Data Generator

Populate your dev database in one command — realistic values, correct FK order, reproducible with seed.

PgDesigner sample data generation dialog showing INSERT statements with realistic values in light theme

Why not just INSERT random values?

Because INSERT INTO users (email) VALUES ('abc123') doesn't look like real data. And if you have 15 tables with foreign keys, you need to insert parents before children, handle circular references, and respect UNIQUE constraints. PgDesigner does all of this automatically.

How it works

FK dependency sort

Kahn's topological sort on the FK graph. Parent tables are always populated first. Deterministic ordering with lexicographic tie-breaking.

3-level column mapping

Per-column override → name heuristic (30 patterns) → type fallback (35+ types). The first match wins.

Circular FK handling

Cycles detected in topo sort → broken FK columns get NULL → deferred UPDATE patches them after all INSERTs. Self-references: first 30% get NULL as root nodes.

Batch INSERT

100-row batches by default. Wrapped in BEGIN/COMMIT transaction. OVERRIDING SYSTEM VALUE for identity columns.

30 name heuristics — realistic values from column names

Column named email? You get john.doe@example.com. Column named price? You get 29.99. Timestamps are coherent: updated_at is always after created_at within the same row.

PatternExample value
email, *_emailalice.smith@example.com
phone, *_phone+1-555-0123
first_nameAlice
last_nameJohnson
username, loginalice_j
passwordaB3$xK9mP2q!
city, country, addressSan Francisco, US, 123 Main St
price, cost, amount29.99
url, link, hrefhttps://example.com/path
created_at2024-03-15 14:30:00+00
updated_atcreated_at + 1–720 hours
title, subjectFive-word generated sentence
description, body, contentParagraph of realistic text
slug, aliasrandom-word-pair
*avatar*, *image*, *photo*picsum.photos URL
status_id1 (references status tables)
sort_order, positionAuto-incrementing

Status tables (statuses, *_status) get well-known values: 1=enabled, 2=disabled, 3=deleted.

35+ type mappings

Every PostgreSQL type gets a sensible default: uuid → UUID v4, jsonb'{}', inet → IP address, point → coordinates, int4range → range literal, tsvector → text search vector. Enums pick a random label. Domains resolve to their base type. Arrays generate 1–3 elements.

Partition-aware: for PARTITION BY RANGE and PARTITION BY LIST, generated values fall within valid partition bounds.

CLI

pgdesigner testdata schema.pgd
pgdesigner testdata -seed 42 schema.pgd
pgdesigner testdata -rows 100 schema.pgd
pgdesigner testdata -tables users,orders schema.pgd
pgdesigner testdata -o testdata.sql schema.pgd

Pipe into psql or save with -o. Seed ensures identical output across runs — useful for test fixtures in CI.