Including CREATE TABLE with Bulk INSERT
Generate a complete SQL script with CREATE TABLE followed by bulk INSERT statements. Types are auto-inferred from JSON data for each SQL dialect.
Detailed Explanation
CREATE TABLE + Bulk INSERT
When you enable the "CREATE TABLE" option, the tool generates a complete SQL script that first creates the table structure, then populates it with data. This is ideal for fresh database setup or migration scripts.
Example Output
CREATE TABLE "employees" (
"id" INTEGER NOT NULL,
"name" VARCHAR(255) NOT NULL,
"email" VARCHAR(255) NOT NULL,
"salary" DECIMAL(10,2) NOT NULL,
"department" VARCHAR(255) NULL,
"active" BOOLEAN NOT NULL
);
INSERT INTO "employees" ("id", "name", "email", "salary", "department", "active")
VALUES
(1, 'Alice', 'alice@company.com', 75000.50, 'Engineering', TRUE),
(2, 'Bob', 'bob@company.com', 62000.00, 'Marketing', FALSE),
(3, 'Charlie', 'charlie@company.com', 95000.75, NULL, TRUE);
Type Inference
The tool infers column types from your JSON values:
| JSON data pattern | Inferred SQL type |
|---|---|
| Integers only | INTEGER |
| Decimals present | DECIMAL(10,2) |
| Strings | VARCHAR(n) where n is rounded up |
| Booleans only | BOOLEAN |
| Mixed booleans + integers | INTEGER |
| Objects or arrays | TEXT |
| Any null present | Column marked NULL |
Dialect-Specific Types
With CREATE TABLE enabled, types adapt to the selected dialect:
| Type | PostgreSQL | MySQL | SQL Server |
|---|---|---|---|
| Boolean | BOOLEAN |
TINYINT(1) |
BIT |
| String | VARCHAR(255) |
VARCHAR(255) |
NVARCHAR(255) |
| Text | TEXT |
TEXT |
NTEXT |
Complete Migration Scripts
Combine CREATE TABLE with transactions for a complete migration script:
- Enable "CREATE TABLE"
- Enable "Wrap in transaction"
- Set your target dialect
- Download the .sql file
The result is a self-contained SQL file that creates and populates the table atomically.
Use Case
You are setting up a new development environment and need a single SQL file that creates the table schema and seeds it with test data from a JSON fixture file.