Database Seed Data Generator
Paste CREATE TABLE statements and get INSERT statements or JSON with values matched to column types and names, foreign keys that resolve and quotes escaped.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Database Seed Data Generator?
The Database Seed Data Generator reads your CREATE TABLE statements and produces test rows for every table: INSERT statements or JSON. Values follow each column's type and name. An email column gets user1@example.com, a phone column gets a 555-01xx number, a created_at TIMESTAMP gets a date-time within the last year, a DECIMAL(10,2) price gets two decimal places, and an ENUM or CHECK (... IN (...)) column gets one of its allowed values.
Keys are handled so the rows load. Integer primary keys run 1 to N, UNIQUE columns get the row number appended, and foreign keys point at ids that exist in the parent table. Tables are written in dependency order, parents first, so you can run the output top to bottom.
Strings use standard SQL quoting with single quotes doubled, and the name list deliberately includes O'Brien and D'Souza so you find escaping bugs in your own code. The generator runs in your browser, produces up to 1,000 rows per table, and does not connect to a database.
- Reads your real CREATE TABLE statements, including foreign keys and ENUMs
- Values chosen from column type and name
- Parent tables first, foreign keys always resolve
- UNIQUE columns stay unique
- SQL INSERT or JSON output, up to 1,000 rows per table
- Runs in your browser
Updated
How to use the Database Seed Data Generator
- Paste one or more CREATE TABLE statements into Database Schema.
- Set Number of Records (1 to 1,000 per table).
- Choose SQL Inserts or JSON Data as the Output Format.
- Click Generate Seed Data, check the output, and click Copy.
Worked example
Two related tables
Input
CREATE TABLE users (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100) NOT NULL, email VARCHAR(255) UNIQUE NOT NULL, created_at TIMESTAMP);
CREATE TABLE posts (id INT PRIMARY KEY, user_id INT NOT NULL REFERENCES users(id), status ENUM('draft','published'));Output
-- users INSERT INTO users (id, name, email, created_at) VALUES (1, 'Ken Liskov', 'user1@example.com', '2026-04-15 07:02:58'); ... -- posts INSERT INTO posts (id, user_id, status) VALUES (1, 1, 'draft');
users comes first because posts references it, every user_id is between 1 and the number of users, and status only takes the ENUM values. Names, dates and picks are random, so your rows will differ.
Background and insight
Seed data has two jobs: making a fresh development database usable and giving tests predictable fixtures. Both work better when the data looks real. A column of "test1", "test2" will not reveal that your UI truncates long names, that your CSV export breaks on an apostrophe, or that a VARCHAR(50) is too short. Names with accents and apostrophes, realistic lengths and plausible dates do.
Reserved values keep fake data from reaching real people. example.com and the other example domains are reserved by RFC 2606, so mail sent to them goes nowhere. In North America, 555-0100 through 555-0199 are set aside for fictional use. The generator uses both.
Explicit ids have a side effect worth knowing about. MySQL and SQLite move their auto-increment counter past the highest id you insert. PostgreSQL does not: the sequence behind a SERIAL or identity column stays at 1, and the next normal insert fails with a duplicate key error until you run SELECT setval(pg_get_serial_sequence('users', 'id'), (SELECT max(id) FROM users)). SQL Server needs SET IDENTITY_INSERT users ON before explicit ids are accepted.
Common use cases
Local development databases
Fill a fresh schema with enough rows to click through the app and see realistic pages.
Testing pagination and sorting
Generate a few hundred rows to check page boundaries, ordering and empty states.
Finding escaping bugs
Load names with apostrophes and accents to see whether your queries, exports and templates handle them.
Fixtures for API mocks
Use the JSON output as mock responses that match your table structure.
Tips and limitations
- In PostgreSQL, reset each sequence after loading explicit ids with setval, or the next insert fails with a duplicate key error.
- Booleans are written as TRUE and FALSE, which MySQL, PostgreSQL and SQLite accept. For SQL Server or Oracle, replace them with 1 and 0.
- Timestamps are plain 'YYYY-MM-DD HH:MM:SS' strings in UTC. Oracle needs TO_TIMESTAMP or an ALTER SESSION date format.
- Self-referencing foreign keys (manager_id pointing at the same table) are left NULL when the column allows it.
- Binary columns are left NULL or empty; generate files separately if your tests need them.
Sources and further reading
- RFC 2606: Reserved Top Level DNS Names, IETF. Reserves example.com and the other example domains
- Sequence Manipulation Functions, PostgreSQL Global Development Group. setval and pg_get_serial_sequence
- SET IDENTITY_INSERT (Transact-SQL), Microsoft. Inserting explicit ids in SQL Server
- SQLite Autoincrement, SQLite. How SQLite picks the next rowid
Frequently asked questions
How do I generate test data from a CREATE TABLE statement?
Paste the CREATE TABLE statements, set the number of rows and click Generate Seed Data. The generator reads each column's name and type and writes matching values, so an email column gets addresses and a DECIMAL column gets numbers with the right scale.
Why does PostgreSQL say duplicate key after I load seed data?
The seed rows set id explicitly, but the identity or SERIAL sequence still starts at 1. Move it forward with SELECT setval(pg_get_serial_sequence('users', 'id'), (SELECT max(id) FROM users)); for each table and later inserts will work.
Do the generated foreign keys point at real rows?
Yes. Tables are ordered so parents are inserted first, and every foreign key value is a number between 1 and the row count of the referenced table, which matches the ids the generator gave the parent rows.
Are apostrophes in seed data escaped correctly?
Yes. Every string is a standard SQL literal with single quotes doubled, so O'Brien is written 'O''Brien'. Those names are included on purpose: if your application breaks on them, real customers would have found it.
Is the seed data safe to use with real email and phone systems?
Emails use example.com, which RFC 2606 reserves so it never receives mail, and phone numbers use the 555-0100 to 555-0199 range set aside for fiction in North America. Still, keep seed data out of production.
Can I get the same seed data every time?
Not from the page, which uses a fresh random seed on each click. The underlying generator accepts a fixed seed, so copy one output and commit it as a fixture file if your tests need stable data.
Is there an in-depth guide to the Database Seed Data Generator?
Yes. “Quotes, NULLs and LIMIT: Writing SQL and Seed Data That Run Everywhere” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.