Chapter 4. SQL Syntax

Table of Contents
4.1. Lexical Structure
4.1.1. Identifiers and Key Words
4.1.2. Constants
4.1.3. Operators
4.1.4. Special Characters
4.1.5. Comments
4.1.6. Operator Precedence
4.2. Value Expressions
4.2.1. Column References
4.2.2. Positional Parameters
4.2.3. Subscripts
4.2.4. Field Selection
4.2.5. Operator Invocations
4.2.6. Function Calls
4.2.7. Aggregate Expressions
4.2.8. Window Function Calls
4.2.9. Type Casts
4.2.10. Collation Expressions
4.2.11. Scalar Subqueries
4.2.12. Array Constructors
4.2.13. Row Constructors
4.2.14. Expression Evaluation Rules
4.3. Calling Functions
4.3.1. Using Positional Notation
4.3.2. Using Named Notation
4.3.3. Using Mixed Notation

Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.

This chapter describes the syntax of SQL. It forms the foundation for understanding the following chapters which will go into detail about how SQL commands are applied to define and modify data.

We also advise users who are already familiar with SQL to read this chapter carefully because it contains several rules and concepts that are implemented inconsistently among SQL databases or that are specific to PostgreSQL.