Datasheet
SQL Fundamentals
21
or a NULL with another string results in a string, not a NULL (NULL in Oracle 11g represents
unknown or missing data). Two vertical bars (
||) are used as the concatenation operator.
Here are two examples:
‘Oracle11g’ || ‘Database’ results in ‘Oracle11gDatabase’.
‘Oracle11g ‘ || ‘Database’ results in ‘Oracle11g Database’.
Operator Precedence
If multiple operators are used in the same expression, Oracle evaluates them in the order of
precedence set in the database engine. Operators with higher precedence are evaluated before
operators with lower precedence. Operators with the same precedence are evaluated from left
to right. Table 1.5 lists the precedence.
TABLE 1.5 SQL Operator Precedence
Precedence Operator Purpose
1
- + Unary operators, negation
2
* / Multiplication, division
3
+ - || Addition, subtraction, concatenation
Using parentheses changes the order of precedence. The innermost parenthesis is evaluated
first. In the expression 1+2*3, the result is 7, because 2*3 is evaluated first and the result is
added to 1. In the expression (1+2)*3, 1+2 is evaluated first, and the result is multiplied
by 3, giving 9.
Literals
Literals are values that represent a fixed value (constant). There are four types of literals:
Text (or character)
Numeric (integer and number)
Datetime
Interval
You can use literals within many of the SQL functions, expressions, and conditions.
Text Literals
A text literal must be enclosed in single quotation marks. Any character between the quo-
tation marks is considered part of the text value. Oracle treats all text literals as though
they were CHAR datatypes for comparison (blank padded). The maximum length of a text
95127c01.indd 21 2/18/09 6:37:09 AM