Book Contents

Book Index

Next Topic

Home

SELECT

Retrieves a result set from one or more tables.

[ AT EPOCH LATEST ] | [ AT TIME 'timestamp' ]

SELECT * | [ ALL | DISTINCT ] expression [ [ AS ] output_name ] [, ...]

[ FROM clause ]

[ WHERE clause ]

[ GROUP BY clause ]

[ HAVING clause ]

[ ORDER BY clause ]

[ LIMIT clause ]

[ OFFSET clause ]

Semantics

AT EPOCH LATEST

 

queries all data in the database up to but not including the current epoch without holding a lock or blocking write operations. See Snapshot Isolation for more information. AT EPOCH LATEST is ignored when applied to temporary tables (all rows are returned).

By default, queries execute under the SERIALIZABLE isolation level, which holds locks and blocks write operations. For optimal query performance, use AT EPOCH LATEST.

AT TIME 'timestamp'

queries all data in the database up to and including the epoch representing the specified date and time without holding a lock or blocking write operations. This is called an Historical Query. AT EPOCH LATEST is ignored when applied to temporary tables (all rows are returned).

*

is equivalent to listing all columns of the tables in the FROM Clause.

Vertica recommends that you avoid using SELECT * for performance reasons. An extremely large and wide result set can cause swapping.

DISTINCT

removes duplicate rows from the result set (or group).The DISTINCT set quantifier must immediately follow the SELECT keyword. Only one DISTINCT keyword can appear in the select list.

expression

forms the output rows of the SELECT statement. The expression can contain:

  • Column References to columns computed in the FROM clause
  • Constants
  • Mathematical Operators
  • String Concatenation Operators
  • Aggregate Expressions
  • CASE Expressions
  • SQL Functions

output_name

specifies a different name for an output column. This name is primarily used to label the column for display. It can also be used to refer to the column's value in ORDER BY and GROUP BY clauses, but not in the WHERE or HAVING clauses.

Notes

SQL Language References

PostgreSQL 8.0.12 Documentation

BNF Grammar for SQL-99

In This Section

FROM Clause

WHERE Clause

GROUP BY Clause

HAVING Clause

ORDER BY Clause

LIMIT Clause

OFFSET Clause