INSERT / UPDATE / DELETE
Feb 23, 2026
·
5
min read
Category: Data Manipulation Language (DML)
Platform Support:
✅ Snowflake | ✅ BigQuery | ✅ Databricks
Description
INSERT adds new rows to a table, UPDATE modifies existing rows, and DELETE removes rows. These are the fundamental DML operations for changing data in tables. Essential for data maintenance, loading, and modifications.
INSERT Syntax
UPDATE Syntax
DELETE Syntax
Platform-Specific Notes
Snowflake:
Supports multi-table INSERT (INSERT ALL)
UPDATE and DELETE are transactional
Can use MERGE for upsert operations
Supports INSERT OVERWRITE for replacing partitions
BigQuery:
INSERT, UPDATE, DELETE require DML quota
Supports INSERT with query results
UPDATE and DELETE can be expensive on large tables
Recommends MERGE for upserts
Supports INSERT by partition
Databricks:
Requires Delta Lake for UPDATE/DELETE on tables
Supports MERGE for upserts
INSERT OVERWRITE for partition replacement
Optimized for large-scale operations
Example 1: INSERT - Single and Multiple Rows
All Platforms:
customers table BEFORE:
customer_id | name | signup_date | |
|---|---|---|---|
(empty) |
customers table AFTER:
customer_id | name | signup_date | |
|---|---|---|---|
101 | John Smith | 2024-01-15 | |
102 | Maria Garcia | 2024-01-16 | |
103 | Sarah Johnson | 2024-01-17 | |
104 | Ahmed Hassan | 2024-01-18 |
Example 2: INSERT with SELECT
All Platforms:
Sample Data:
customers:
customer_id | name | |
|---|---|---|
101 | John Smith | |
102 | Maria Garcia |
orders:
order_id | customer_id | total |
|---|---|---|
1 | 101 | 600.00 |
2 | 101 | 500.00 |
3 | 102 | 300.00 |
vip_customers table AFTER INSERT:
customer_id | name | total_spent | |
|---|---|---|---|
101 | John Smith | 1100.00 |
Example 3: UPDATE - Basic Updates
All Platforms:
products table BEFORE:
product_id | product_name | category | price | last_updated |
|---|---|---|---|---|
1 | Mouse | Electronics | 29.99 | 2023-12-01 |
2 | Keyboard | Electronics | 89.99 | 2023-12-01 |
3 | Desk | Furniture | 299.99 | 2023-12-01 |
products table AFTER:
product_id | product_name | category | price | last_updated |
|---|---|---|---|---|
1 | Mouse | Electronics | 32.99 | 2024-01-20 |
2 | Keyboard | Electronics | 98.99 | 2024-01-20 |
3 | Desk | Furniture | 299.99 | 2023-12-01 |
Example 4: UPDATE with JOIN/Subquery
Snowflake:
BigQuery:
Databricks:
customers table BEFORE:
customer_id | name | tier |
|---|---|---|
101 | John Smith | Standard |
102 | Maria Garcia | Standard |
customers table AFTER:
customer_id | name | tier |
|---|---|---|
101 | John Smith | VIP |
102 | Maria Garcia | Standard |
Example 5: DELETE - Conditional Deletion
All Platforms:
orders table BEFORE:
order_id | order_date | total |
|---|---|---|
1 | 2022-06-15 | 250.00 |
2 | 2023-01-20 | 180.00 |
3 | 2024-01-25 | 320.00 |
orders table AFTER (deleted old orders):
order_id | order_date | total |
|---|---|---|
2 | 2023-01-20 | 180.00 |
3 | 2024-01-25 | 320.00 |
Example 6: INSERT with Default and Computed Values
All Platforms:
INSERT / UPDATE / DELETE Comparison
Operation | Purpose | Affects | Returns |
|---|---|---|---|
INSERT | Add new rows | 0 to many rows | Row count |
UPDATE | Modify existing rows | 0 to many rows | Row count |
DELETE | Remove rows | 0 to many rows | Row count |
MERGE | Upsert (insert or update) | 0 to many rows | Row count |
MERGE (Upsert) Example
All Platforms:
Transaction Best Practices
All Platforms:
Common Use Cases
INSERT: Load new data, migrate records, create test data
UPDATE: Correct errors, apply business rules, update status
DELETE: Remove old data, clean duplicates, archive records
MERGE: Synchronize tables, incremental loads, upserts
Performance Tips
Batch operations: Insert/update/delete in batches, not row-by-row
Use MERGE: More efficient than separate INSERT/UPDATE
Disable indexes: For large bulk loads, disable then rebuild
Use TRUNCATE: Instead of DELETE for all rows (if appropriate)
Filter efficiently: Use indexes in WHERE clauses
Avoid triggers: Can slow down DML operations
Best Practices
Always use WHERE: For UPDATE and DELETE (avoid accidents)
Test on small datasets: Verify logic before large operations
Use transactions: For related operations
Backup before bulk changes: Safety first
Log changes: Track who changed what and when
Validate data: Check constraints and data quality
Consider soft deletes: Use status flags instead of DELETE





