SELECT

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

Synopsis

The SELECT statement retrieves (part of) rows of specified columns that meet a given condition from a table. It specifies the columns to be retrieved, the name of the table, and the condition each selected row must satisfy.

Syntax

Diagram

SELECT - 图1

Grammar

  1. select ::= SELECT [ DISTINCT ] { '*' | column_name [ ',' column_name ... ] }
  2. FROM table_name [ WHERE where_expression ];

Where

  • table_name and column_name are identifiers.

Semantics

  • An error is raised if the specified table_name does not exist.
  • * represents all columns.

WHERE Clause

  • The where_expression must evaluate to boolean values.
  • The where_expression can specify conditions for any column.

While the where clause allows a wide range of operators, the exact conditions used in the where clause have significant performance considerations (especially for large datasets).

See Also

CREATE TABLEINSERTUPDATEDELETEOther PostgreSQL Statements