Ads by ProfitSence

PostgreSQL insert into Code Example

Last Updated on Wednesday 5th Oct 2022

PostgreSQL insert into

Add new data to a table

					INSERT INTO table_name [ ( column_name [, ...] ) ]
    VALUES ( { expression | DEFAULT } [, ...] )


If you want to add data to all columns in the table with values

					INSERT INTO table_name VALUES (value1, value2, ...)


If you want to add data by specifying a specific column in the table.

					INSERT INTO table_name (column_name1, column_name2, ...) VALUES (value1, value2, ...)

					create table dbstu.students (
  id integer, 
  name varchar(10), 
  address varchar(10)


Adds new data to the table.

					insert into dbstu.students values (1, 'Alex', 'Germany');


You can see that data has been added to the table by using below.

					select * from dbstu.students;


Let's add data by specifying values.

					insert into dbstu.students (id, name) values (2, 'Ball');