Syntax
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
Explanation:
table_name
: Name of the table to insert data into.(column1, column2, ...)
: Optional list of columns to insert values into.VALUES (value1, value2, ...)
: Values corresponding to the columns.
Example 1: Insert a Single Row
INSERT INTO employees (name, email, hire_date)
VALUES ('John Doe', 'john.doe@example.com', '2025-05-22');
If id
is a serial auto-increment column, you don’t need to specify it.
Example 2: Insert Multiple Rows
INSERT INTO employees (name, email, hire_date)
VALUES
('Alice Smith', 'alice.smith@example.com', '2024-11-10'),
('Bob Johnson', 'bob.johnson@example.com', '2023-08-15');
Where to run
You can run these commands inside the psql
terminal or pgAdmin query editor after connecting to your database.
Reference: Official PostgreSQL Documentation: INSERT