Академический Документы
Профессиональный Документы
Культура Документы
Single-row functions return a single result row for every row of a queried table or view. These functions can
appear in select lists, WHERE clauses, START WITH andCONNECT BY clauses, and HAVING clauses
Numeric Functions
Numeric functions accept numeric input and return numeric values. Most numeric functions
return NUMBER values that are accurate to 38 decimal digits.
ABS
Syntax
Purpose
ABS returns the absolute value of n.
FROM DUAL;
Absolute
----------
15
CEIL
Syntax
select ceil(-3.3) from dual select ceil(-3.6) from dual select ceil(3.3) from dual select ceil(3.6) from dual
3 3 4 4
FLOOR
Syntax
select floor(3.6)
select floor(-3.3) from dual select floor(-3.6) from dual select floor(3.3) from dual
from dual
-4 -4 3 3
MOD
Syntax
Purpose
MOD returns the remainder of n2 divided by n1. Returns n2 if n1 is 0.
FROM DUAL;
ROUND (number)
Syntax
round_number::=
If integer is negative result is 0 either n is positive or negative
TRUNC (number)
Syntax
trunc_number::=
Purpose
The TRUNC (number) function returns n1 truncated to n2 decimal places. If n2 is omitted, then n1 is
truncated to 0 places. n2 can be negative to truncate (make zero) n2 digits left of the decimal point.
CONCAT
Syntax
FROM employees
Job
------------------------------------------------------
INITCAP
Syntax
Capitals
---------
The Soap
LOWER
Syntax
LPAD
Syntax
Purpose
LPAD returns expr1, left-padded to length n characters with the sequence of characters in expr2. This
function is useful for formatting the output of a query.
RPAD
Syntax
LTRIM
Syntax
Ltrim('******hello','*')
hello
If you do not specify set,
Ltrim(' hello')
then it defaults to a single
hello blank.
RTRIM
Syntax
Rtrim('hello******','*')
hello
If you do not specify set,
Rtrim('hello ')
then it defaults to a single
hello blank.
TRIM
Syntax
Purpose
TRIM enables you to trim leading or trailing characters (or both) from a character string.
If trim_character or trim_source is a character literal, then you must enclose it in single quotation
marks.
If you specify LEADING, then Oracle Database removes any leading characters equal to trim_character.
If you specify TRAILING, then Oracle removes any trailing characters equal to trim_character.
If you specify BOTH or none of the three, then Oracle removes leading and trailing characters equal
to trim_character.
If you do not specify trim_character, then the default value is a blank space.
If you specify only trim_source, then Oracle removes leading and trailing blank spaces.
The function returns a value with data type VARCHAR2. The maximum length of the value is the length
of trim_source.
If either trim_source or trim_character is null, then the TRIM function returns null
REPLACE
Syntax
Purpose
REPLACE returns char with every occurrence of search_string replaced with replacement_string.
If replacement_string is omitted or null, then all occurrences of search_string are removed.
If search_string is null, then char is returned
replace('****hello***students****','*') replace('****hello***students****','*','$')
hellostudents $$$$hello$$$students$$$$
SUBSTR
Syntax
substr::=
select substr('hello',0) from dual select substr('hello',-1,1) from dual select substr('hello',-1,-1) from dual
hello o null
LENGTH
Syntax
length::=
Length in character
7
INSTR functions
The INSTR functions (INSTR, INSTRB, INSTRC, INSTR2, and INSTR4) searches a string for a substring
using characters and returns the position in the string that is the first character of a specified occurrence of
the substring. The functions vary in how they determine the position of the substring to return.
Syntax
position is an nonzero integer indicating the character of string where Oracle Database begins the
search.
If position is negative, then Oracle counts backward from the end of string and then searches
backward from the resulting position.
occurrence is an integer indicating which occurrence of string Oracle should search for. The value
of occurrence must be positive.
Datetime Functions
Datetime functions operate on date (DATE), timestamp (TIMESTAMP, TIMESTAMP WITH TIME ZONE,
and TIMESTAMP WITH LOCAL TIME ZONE), and interval
(INTERVAL DAY TO SECOND, INTERVAL YEAR TO MONTH) values.