Databases Reference
In-Depth Information
Employee: Ford Dept: 20
Employee: Miller Dept: 10
14 rows selected.
In the above query, there are two columns in the output: the string literal
'Employee: ' concatenated with the result of a string function on the employee
name and the string literal 'Dept: ' concatenated with the department number
of the employee. Notice how the case of a string is preserved within the single
quotes. This example demonstrates both the concatenation operator || and the
CONCAT function. Which you use depends on how many strings are to be concat-
enated, as well as your programming style. If you have more than two or three
strings to concatenate, using vertical bars is more readable than using the CONCAT
function over and over. However, if you are dealing with translating your queries
from one character set to another on a different platform, vertical bars may not
translate correctly; in this case, using the CONCAT function would be the best
option for concatenating any number of strings.
Numeric Literals
Numeric literals in Oracle are very straightforward and are similar to what is
allowed in many programming languages: the digits 0-9, an optional decimal
point, an optional sign, and an optional exponent using the letter E with its own
optional sign. Here are some valid numeric literals:
numeric literal
A constant that can consist of numeric
digits, plus the characters +, -, ., and E.
1.456
-.01
00000052
+12.10
-3.774E-16
Numbers are stored internally in scientific notation, with up to 20 bytes for
the mantissa and 1 byte for the exponent. This results in a maximum precision
of up to 38 digits.
Operators and Operator Precedence
Operator precedence specifies the order in which the operators are applied to the
arguments of a mathematical expression when there is more than one operator
in the expression. Think back to your middle school algebra class when you had
to answer questions such as “A man bought 20 chickens and ducks, with a $2
discount per chicken and 50 cent discount per duck…” and you'll probably
remember a few things about the order in which you had to evaluate an expres-
sion, once you figured out why a man was buying the chickens and ducks.
Search WWH ::




Custom Search