PostgreSQL: Insert Query Example
PostgreSQL: Insert Query Example
The INSERT command in PostgreSQL is used to add records to a table. It is part of the Data Manipulation Language (DML) and allows you to insert one or many rows with defined values. :contentReference[oaicite:1]{index=1}
Basic Syntax
INSERT INTO table_name (column1, column2, column3)
VALUES (value1, value2, value3);
If you are inserting values into all the columns of a table in order, you can skip naming the columns:
INSERT INTO table_name
VALUES (value1, value2, value3);
Example — Insert Data
CREATE TABLE employee (
id BIGINT PRIMARY KEY,
name VARCHAR(100),
role VARCHAR(100)
);
INSERT INTO employee VALUES
(1, 'Alice', 'Developer'),
(2, 'Bob', 'Manager');
By grouping rows inside the VALUES clause, you can insert multiple rows in one statement. :contentReference[oaicite:2]{index=2}
Comments
Post a Comment