SQL Syntax Definitions

Statement or Query

One or more syntax elements terminated by a semicolon.

Scalar Expressions and Boolean Predicates

Scalar expressions represent a single data value, either a numeric value or a string from a constant specification. Examples include:
  • 1
  • 'hello there'
  • '31-DEC-60'd)
  • a function [for example, avg(a*b)]
  • a column or variable (for example, foo.bar)
  • the case expression
  • a subquery that returns a single run-time value
.
Boolean predicates are either true or false. They are used in WHERE clauses, having clauses, and in the case expression. You cannot select predicates, nor can you assign them to columns (that is, in an update statement). Scalar expressions and Boolean predicates cannot be used interchangeably, although you can mix the expressions in SAS SQL.

Strings

SPD Server SQL strings are character streams that are delimited by either single or double quotation marks. If you use a single quotation mark to begin a string, you must use a single quotation mark to terminate the string. To embed a single quotation mark in a string, use two single quotation marks together:
SELECT 'it''s a wonderful life' from mytable. 
You can use double quotation marks in the same way. You can use double quotation marks as delimiters:
SELECT "it's a wonderful life" from mytable.
Some of the SQL syntax specifications in this chapter reference user-defined or database-specific strings. Delimit these strings in brackets or parentheses. Characters between the delimiters are considered part of the string up to, but not including, the matching delimiter.
   CONNECT to sasspds(
     user='john'
     passwd='foobar'
     options=(a b c)
     );

The dbms_options string is
    user='john'
    passwd='foobar'
    options=(a b c).
In this example, the first opening parenthesis is considered part of the string. It is not the matching termination delimiter.

Identifiers

Identifiers are the names of librefs, tables, indexes and columns, as well as table and column aliases.

Reserved Keywords

You use keywords to initiate statements and syntax elements, for example, WHERE or GROUP BY clauses. Keywords are reserved. You cannot use them for identifiers because this use introduces ambiguity. For example, select unique from; is a valid but ambiguous statement. The following list contains current SPD Server keywords. Some of the words are reserved for future enhancements to SPD Server SQL.
add, all, alter, and, any, as, asc, async, begin, between, both, by,
calculated, cascade, case, char, character, column, connect,
connection, contains, contents, copy, corr, corresponding, create,
cross, date, dec, decimal, default, delete, desc, describe,
dictionary, disconnect, distinct, double, drop, else, end, engname,
engopt, eq, except, execute, exists, false, float, for, format, from,
full, ge, grant, group, gt, having, in, index, indexes, informat,
inner, insert, int, integer, intersect, into, is, join, label, le,
leading, left, libref, like, load, lower, lt, match, missing, modify,
natural, ne, no, not, notin, null, num, numeric, on, operation, option,
or, order, outer, overlaps, partial, precision, privileges, public,
real, references, reset, restrict, revoke, right, select, set,
smallint, some, table, then, to, trailing, trim, true, union, unique,
unknown, update, upper, using, validate, values, varchar, verbose,
view, when, where, with, without, yes