Some special character symbols help to make up the "punctuation" of a SQL statement, much like parentheses, periods and commas do in the English language. Table 3-4 shows some common PostgreSQL-recognized syntactic symbols.

Table 3-4. Punctuation Symbols




Asterisk: used with the SELECT command to query all columns in the table, and used with the COUNT aggregate function to count all rows in a table.


Parentheses: these are used to group expressions, enforce operator precedence, and to make function calls. The use of parentheses is highly subjective to the context in which they are used.


Brackets: used in the selection of specific elements in an array, or in the declaration of an array type (e.g., with the CREATE TABLE command).


Semi-colons: used to terminate a SQL command. The only place it can be used within a statement is within a string constant, or within a quoted identifier.


Commas: Some commands use the comma to separate elements within a list.


Period: used in floating point constants (e.g., 3.1415 ), as well as to reference column names as children of tables (e.g., table_name.column_name ).


Colons: used to select slices from arrays.


Dollar sign: used in the body of a function definition to represent a positional parameter , or argument.