PostgreSQL – INSERT INTO Query

To insert a row into PostgreSQL table, you can use INSERT INTO query with the following syntax.

</>
Copy
INSERT INTO table_name(
	column1, column2,.., columnN)
	VALUES (value1, value2,.., valueN);

where

  • table_name is the name of table in which you would like to insert the row.
  • column1, column2,.., columnN are the columns of the table.
  • value1, value2,.., valueN are the respective values of the columns.

Example 1 – INSERT INTO table

In the following example, we are inserting an entry into students table of mydb database.

</>
Copy
 INSERT INTO students(
    id, name, age)
    VALUES (1, 'Jack', 24);