Categories of Syntax

To begin to use SQL, readers should 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 a database object, such as a database, a table, a constraint on a table, a column 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 to be 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. Keywords such as SELECT, GRANT, DELETE, or CREATE are words that cannot be used as identifiers within the database platform. These are usually commands or SQL statements. Reserved words are words that may become reserved some time in the future. Elsewhere in the book, we use the term keyword to describe both concepts. You can circumvent the restriction on using reserved words and keywords as identifiers by using quoted identifiers, which will be described in a moment. However, this is not recommended!

Identifiers

Keep in mind that RDBMSs are built upon set theory. In ...

Get SQL in a Nutshell, 3rd 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.