beginner
INSERT Statement
6 min readLast updated: 2026-07-23
Overview
The INSERT statement adds new rows of data into a database table.
Learning Objectives
- Insert single or multiple row values into tables.
- Copy data from one table to another using
INSERT INTO ... SELECT. - Handle default column constraints.
Detailed Concept Explanation
INSERT operates in two primary modes:
- Direct Value Insertion: Inserting literal values specified in a
VALUESclause. - Subquery Insertion: Inserting rows generated by a
SELECTstatement into a target table (INSERT INTO target SELECT ...).
Code Examples
SQL
sql
-- Insert multiple explicit rows
INSERT INTO employees (emp_id, name, department_id, salary)
VALUES
(101, 'Alice Smith', 3, 85000),
(102, 'Bob Jones', 2, 62000);
-- Bulk insert from a query (CTAS pattern)
INSERT INTO archive_orders (order_id, customer_id, order_date)
SELECT order_id, customer_id, order_date
FROM orders
WHERE order_date < '2025-01-01';
Best Practices
- Explicit Column Lists: Always specify target column names explicitly (
INSERT INTO table (col1, col2)). Avoid implicitINSERT INTO table VALUES (...)because schema column order changes will break your query.
Summary
INSERT adds new records to tables using literal VALUES or bulk results from SELECT queries.