Normal view

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

Insert data on table

18 May 2024 at 19:32

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:

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:

❌
❌