Professional Documents
Culture Documents
Special Tables
Grants
Select
Select varlist
From tablename
Where criteria
Group By varlist
Having criteria
Order By varlist;
ALL_TABLES
ALL_VIEWS
ALL_TAB_COLS
ALL_CONSTRAINTS
ALL_DEPENDENCIES
DICTIONARY
DDL
Select varlist
From tablename
Where Rownum <= number;
More
Select varlist
From tablename,
tablename
Where criteria;
Select varlist
From tablename
Left/Right/Full Join tablename
On criteria;
Describe tablename;
Select varlist
From tablename
As Of Timestamp timestamp;
('03-JUN-14 00:00:00',
'DD-Mon-RR HH24:MI:SS.FF')
Select tablename
Union
Select tablename;
Select tablename
DML
Union All
Select tablename;
Select tablename
Intersect
Select tablename;
Select tablename
Where criteria;
Minus
Select tablename;
Views
www.codeitmagazine.com
Function
Definition
to_char(string, <format>)
Text
Convert a string to text
to_date(string, <format>)
Convert a string to a date
to_number(string)
Convert a string to a number
substr(string, start, length)
Extracts part of a string
upper(string)
Converts a string to upper case
lower(string)
Converts a string to lower case
lpad(string, length, char)
Pads a string from the left
rpad(string, length, char)
Pads a string from the right
length(string)
Returns the length of a string
replace(string, chars, new)
Replaces patterns in a string
translate(string, chars, new)
Replaces characters in a string
trim(string)
Removes leading and trailing spaces
concat(string1, string2)
Combines strings
greatest(col1, col2)
Math
Returns the largest column value in a row
least(col1, col2)
Returns the smallest column value in a row
abs(number)
Returns the absolute value
round(number, places)
Rounds a number
add_months(date, number)
Date
Adds months to a date
sysdate, current_timestamp
Returns today's date, timestamp
trunc(date)
Removes the time from a timestamp
min(col)
Aggregate
Returns the smallest value in a column
max(col)
Returns the largest value in a column
count(col)
Returns the number of values
sum(col)
Returns the sum of values
avg(col)
Returns the average value
nvl(value, value)
More
Find the first non-null value
coalesce(value, value)
Find the first non-null value
decode(variable, value, result, value, result, , elseresult)
Case When criteria Then value When criteria Then value Else value End
In (item, item, )
www.codeitmagazine.com
Example
to_char(sysdate, 'YYYY')
to_date('31dec2014')
to_number('4')
substr('12345', 3, 2)
upper('abc')
lower('ABC')
lpad('abc', 5, '0')
rpad('abc', 5, '0')
length('abc')
replace('abcde', 'bc', 'xx')
translate('abcde', 'ac', 'xx')
trim(' abc ')
concat('abc', 'def')
abs(-1)
round(1.234, 1)
add_months(sysdate, 1)
nvl('', '1')
coalesce('', '1')
Christopher Johnson