Generate Seed Data for a User Table
Learn how to generate realistic INSERT statements for a users table with names, emails, and timestamps. Step-by-step guide with SQL examples.
Detailed Explanation
Seeding a User Table
A users table is the most common starting point for database seeding. The seed generator recognizes column naming conventions and produces contextually appropriate fake data for each field.
Example Schema
CREATE TABLE users (
id SERIAL PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
age INTEGER,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
What the Generator Produces
| Column | Generated Data |
|---|---|
id |
Auto-increment (1, 2, 3, ...) — skipped in INSERT |
first_name |
Realistic first names (e.g., "James", "Emily") |
last_name |
Realistic last names (e.g., "Johnson", "Garcia") |
email |
Formatted emails like james.johnson42@gmail.com |
age |
Random integers between 18 and 80 |
is_active |
Random TRUE/FALSE values |
created_at |
Random timestamps within 2020–2025 |
Column Name Heuristics
The generator matches column names to data categories using substring matching. For example, any column containing "email" in its name triggers the email generator, regardless of whether the column is called email, user_email, or contact_email. Similarly, first_name, firstname, and fname all trigger the first name generator.
Handling Auto-Increment
Columns marked as SERIAL, AUTO_INCREMENT, or BIGSERIAL are automatically excluded from the INSERT statement’s column list because the database assigns their values. This prevents conflicts with database-managed sequences.
Use Case
You are building a new web application and need test users in your development database to verify authentication flows, user profile pages, and admin dashboards. Instead of creating accounts manually through the UI, you seed the database directly with realistic user records.