Basic Syntax
Create Single Record
| Database | Output |
|---|---|
| PostgreSQL | INSERT INTO users (name, email, age) VALUES ('John', 'john@example.com', 30) |
| MySQL | INSERT INTO users (name, email, age) VALUES ('John', 'john@example.com', 30) |
| MongoDB | db.users.insertOne({ name: 'John', email: 'john@example.com', age: 30 }) |
| Redis | HMSET users:1 name "John" email "john@example.com" age 30 |
Data Types
Multiple Fields
With Timestamps
Bulk Insert
Insert multiple records at once. Each record is wrapped in square brackets with= assignments.
| Database | Output |
|---|---|
| PostgreSQL | INSERT INTO users (name, age) VALUES ('Alice', 25), ('Bob', 30), ('Charlie', 35) |
| MySQL | INSERT INTO users (name, age) VALUES ('Alice', 25), ('Bob', 30), ('Charlie', 35) |
| MongoDB | db.users.insertMany([{ name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Charlie', age: 35 }]) |
Upsert
Insert or update if exists. Specify conflict field(s) withON.
| Database | Output |
|---|---|
| PostgreSQL | INSERT INTO users (...) ON CONFLICT (email) DO UPDATE SET name = 'John Updated', login_count = 1 |
| MySQL | INSERT INTO users (...) ON DUPLICATE KEY UPDATE name = 'John Updated', login_count = 1 |
| MongoDB | db.users.updateOne({ email: 'john@example.com' }, { $set: { ... } }, { upsert: true }) |
Upsert with Composite Key
Replace
Delete and insert (MySQL-specific behavior).| Database | Output |
|---|---|
| PostgreSQL | Uses UPSERT behavior |
| MySQL | REPLACE INTO users (id, name, email) VALUES (...) |
| MongoDB | db.users.replaceOne({ _id: 1 }, { ... }) |
Complete Examples
User Registration
E-commerce Order
Bulk Product Import
Next Steps
Update Data
Modify existing records
Delete Data
Remove records

