The PostgreSQL Insert statement is used to insert rows in the table. Using a single Insert statement one row is inserted, but to insert multiple rows, we can use the multiple insert statements in the form of script. To insert data in the table, we should have insert permission.

The syntax of the PostgreSQL Insert statement is as mentioned below.


Syntax:

INSERT INTO table_name ( column1,column2,column2.... ) VALUES(value1,value2,value3....)

Now let us see an example of the Insert statement in the below section. We will create a table named PRODUCTS_DETAIL and insert some values.


Command:

postgres=# CREATE TABLE products_detail
(product_number INTEGER,
product_name TEXT,
product_price NUMERIC,
product_catagory VARCHAR(30)
);
postgres=# INSERT INTO products_detail VALUES(101,'Candy',10,'A001');
postgres=# INSERT INTO products_detail VALUES(102,'Rice',30,'A002');
postgres=# INSERT INTO products_detail VALUES(103,'Egg',5,'A003');
postgres=# INSERT INTO products_detail VALUES(104,'Suger',3,'A004');
postgres=# INSERT INTO products_detail VALUES(105,'Bean',1,'A005');
postgres=# INSERT INTO products_detail VALUES(106,'Wheat',1,'A006');
postgres=# INSERT INTO products_detail VALUES(107,'Potato',2,'A007');
postgres=# INSERT INTO products_detail VALUES(108,'Chicken',6,'A008');
postgres=# INSERT INTO products_detail VALUES(109,'Tomato',8,'A009');
postgres=# INSERT INTO products_detail VALUES(110,'Popcorn',3,'A010');


Output:

postgresql insert command

To verify the records, we can use the Select statement to verify the inserted records.


postgres=# SELECT * FROM products_detail;


Output:

postgresql select table records command