INSERT

AttentionThis page documents an earlier version. Go to the latest (v2.1)version.

Synopsis

The INSERT statement adds a row to a specified table.

Syntax

Diagram

INSERT - 图1

Grammar

  1. insert ::= INSERT INTO table_name ['(' column [ ',' column ... ] ')']
  2. VALUES '(' value [ ',' value ... ] ')';

Where

  • table_name and column are identifiers.
  • value can be any expression.

Semantics

  • An error is raised if the specified table_name does not exist.
  • Each of primary key columns must have a non-null value.

VALUES Clause

  • The values list must have the same length as the columns list.
  • Each value must be convertible to its corresponding (by position) column type.
  • Each value literal can be an expression.

See Also

CREATE TABLEDELETESELECTUPDATEOther PostgreSQL Statements