❌

Reading view

There are new articles available, click to refresh the page.

Insert data on table

INSERTΒ statement to insert a new row into a table.

INSERT INTO table1(column1, column2, …)
           VALUES (value1, value2, …);

In this syntax:

  • First, specify the name of the table (table1) that you want to insert data after theΒ INSERT INTOΒ keywords and a list of comma-separated columns (colum1, column2, ....).
  • Second, supply a list of comma-separated values in parenthesesΒ (value1, value2, ...)Β after theΒ VALUESΒ keyword. The column and value lists must be in the same order.

RETURNING clause

  • TheΒ INSERTΒ statement has an optionalΒ RETURNINGΒ clause
  • returns the information of the inserted row.
INSERT INTO table1(column1, column2, …)
VALUES (value1, value2, …)
RETURNING *;

It return the inside table

We can return by any parameters.

Summary

  • Use PostgreSQLΒ INSERTΒ statement to insert a new row into a table.
  • Use theΒ RETURNINGΒ clause to get the inserted rows.

Reference:

❌