1.1. Lexical Conventions

SQL statements are composed of commands, variables, and operators, which are described in detail in this and subsequent chapters. A SQL statement is constructed from:

  • Characters A through Z (or the equivalent from your database character set)

  • Numbers 0 through 9

  • Spaces

  • The following special characters: + - * = ? ! @ ( ) _ . , < > | $ #

Oracle strongly discourages the use of # and $.

Other characters, such as &, are also used in SQL statements, but may be intercepted and interpreted by SQL*Plus if you are using that tool. See Chapter 6 for more information.

A SQL statement can contain one or more of the following items anywhere a single space can occur:

  • Tab

  • Carriage return

  • Multiple spaces

  • Comments

Certain components of SQL statements (such as variable names and strings) may contain other characters, as long as they are enclosed in double quotes.

The following two SELECT statements, for example, are evaluated in exactly the same way by Oracle and both return the same result set:

SELECT ename,empno,sal FROM scott.emp WHERE sal>500;

SELECT ename, 
       empno, sal
FROM   scott.emp
WHERE  sal > 500;

SQL is generally not case-sensitive, so case is not significant except in literals, which are enclosed in quotes.

Be aware that a variable name enclosed in double quotes will ...

Get Oracle SQL: the Essential Reference 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.