Integration · CockroachDB · Distributed SQL
Generate CockroachDB test data, with foreign keys intact
Multi-table fixtures that load with
userfile upload +
IMPORT INTO via
import_cockroachdb.sql. Free web sessions.
Short answer
Design a multi-table schema in SynthForge, generate, and download the CockroachDB export.
You get import_cockroachdb.sql (CREATE TABLE with FKs plus
IMPORT INTO … CSV DATA) and per-table CSVs. Upload each CSV to
userfile first, then run the script. Every child row references a
real parent by construction.
Why generate rather than hand-roll
Distributed SQL still needs multi-table fixtures for integration tests and staging. Hand-rolled seed scripts drift; broken foreign keys fail later under concurrency.
SynthForge sorts tables by dependency, generates parents first, and samples FKs from IDs that exist. The same schema also exports Postgres-style loaders when you run CRDB and Postgres side by side.
How to do it
1. Define the schema
Describe tables in plain English, build them in the visual editor, or paste CREATE TABLE DDL. AI forge and SQL import both produce multi-table schemas with single-column foreign keys.
2. Set cardinality (optional)
Use relationship ratios such as "1 to 4 orders per customer" instead of inventing every child row count. Parents generate first; child foreign keys are sampled from real parent IDs.
3. Generate and export CockroachDB
Pick CockroachDB as the SQL dialect (or include SQL export in formats). The download ZIP contains import_cockroachdb.sql (CREATE TABLE with FKs plus IMPORT INTO … CSV DATA loaders) and csv/<table>.csv data files. Types use STRING, INT, and JSONB-friendly mappings.
4. Upload CSVs to userfile, then run the import script
CockroachDB IMPORT INTO reads from userfile:// (or cloud storage URLs), not from arbitrary local paths. The script header documents the prerequisite. Extract the ZIP, upload each CSV so the destination path matches userfile:///csv/<table>.csv, then run the SQL script.
# From the extracted bundle directory
export DATABASE_URL='postgresql://root@localhost:26257/defaultdb?sslmode=disable'
# or your Cockroach Cloud connection string
for f in csv/*.csv; do
base=$(basename "$f")
cockroach userfile upload "$f" "csv/$base" --url "$DATABASE_URL"
done
cockroach sql --url "$DATABASE_URL" -f import_cockroachdb.sql
# Loaders look like:
# IMPORT INTO "customers" CSV DATA ('userfile:///csv/customers.csv')
# WITH skip = '1', nullif = '';
# IMPORT INTO "orders" CSV DATA ('userfile:///csv/orders.csv')
# WITH skip = '1', nullif = ''; 5. Local single-node / Docker tip
For a quick local check, start an insecure single-node (dev only), upload, and import. Production Cockroach Cloud uses the same userfile (or external storage) pattern with TLS credentials.
# Dev only
docker run -d --name crdb -p 26257:26257 cockroachdb/cockroach:latest-v24.3 \
start-single-node --insecure
# then userfile upload + cockroach sql -f import_cockroachdb.sql as above 6. (Optional) Agent path
With an API key and hosted MCP, agents can run description_to_dataset, download the ZIP, upload userfiles, and load with the same import_cockroachdb.sql. First API key includes 10 free credits; web sessions stay free.
# MCP endpoint: https://mcp.synthforge.io/mcp
# Auth: Authorization: Bearer sfk_live_…
# Docs: https://synthforge.io/docs/mcp Frequently asked questions
Why userfile upload before IMPORT?
Does CockroachDB enforce the foreign keys?
Does this work with Cockroach Cloud?
How large a dataset can I generate?
Can I use the same schema for Postgres or SQL Server?
Does SynthForge use my real production data?
Related
Ready to seed CockroachDB staging?
Generate multi-table Cockroach data with real foreign keys, upload to userfile, IMPORT once. No credit card for the web app.