Categories of Syntax

To begin to use SQL, you must understand how statements are written. SQL syntax falls into four main categories. Each category is introduced in the following list and then explained in further detail in the sections that follow:

Identifiers

Describe a user- or system-supplied name for database objects, such as a database, a table, a constraint on a table, the columns in a table, a view, etc.

Literals

Describe a user- or system-supplied string or value that is not otherwise an identifier or a keyword. Literals may be strings like “hello”, numbers like 1234, dates like “Jan 01, 2002”, or Boolean values like TRUE.

Operators

Are symbols specifying an action performed on one or more expressions, most often in DELETE , INSERT, SELECT, or UPDATE statements. Operators are also used frequently in the creation of database objects.

Reserved words and keywords

Have special meaning to the database SQL parser, such as SELECT, GRANT, DELETE, or CREATE. Reserved words are words that cannot be used as identifiers within the database platform, usually commands or SQL statements. Keywords are words that may become reserved some time in the future. You can circumvent the restriction on using reserved words and keywords as identifiers through quoted identifiers, described in a moment. This is not recommended! Elsewhere in the book (besides here), we use the term keyword to describe both concepts.

Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.