0% found this document useful (0 votes)
66 views3 pages

Ascii CHR Concat Convert Dump: Function Example Result Purpose

The document describes various string and date functions in Oracle SQL. Some key functions include: 1. String functions like ASCII, CHR, CONCAT, INSTR, LENGTH, LOWER, LTRIM, REGEXP_COUNT, REGEXP_INSTR, REGEXP_REPLACE, SUBSTR, TRANSLATE, TRIM, and UPPER that perform operations like returning character codes, concatenating strings, searching/extracting substrings, trimming strings, and converting case. 2. Date functions like ADD_MONTHS, CURRENT_DATE, CURRENT_TIMESTAMP, DBTIMEZONE, EXTRACT, FROM_TZ, LAST_DAY, LOCALTIMESTAMP, MONTHS_BETWEEN,

Uploaded by

Glenutzu Samp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views3 pages

Ascii CHR Concat Convert Dump: Function Example Result Purpose

The document describes various string and date functions in Oracle SQL. Some key functions include: 1. String functions like ASCII, CHR, CONCAT, INSTR, LENGTH, LOWER, LTRIM, REGEXP_COUNT, REGEXP_INSTR, REGEXP_REPLACE, SUBSTR, TRANSLATE, TRIM, and UPPER that perform operations like returning character codes, concatenating strings, searching/extracting substrings, trimming strings, and converting case. 2. Date functions like ADD_MONTHS, CURRENT_DATE, CURRENT_TIMESTAMP, DBTIMEZONE, EXTRACT, FROM_TZ, LAST_DAY, LOCALTIMESTAMP, MONTHS_BETWEEN,

Uploaded by

Glenutzu Samp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Function Example Result Purpose

ASCII ASCII(‘A’) 65 Returns an ASCII code value of a character.


CHR CHR(’65’) ‘A’ Converts a numeric value to its corresponding ASCII character.
CONCAT CONCAT(‘A’,’BC’) ‘ABC’ Concatenate two strings and return the combined string.
CONVERT CONVERT( ‘Ä Ê Í’, ‘US7ASCII’,  ‘A E I’ Convert a character string from one character set to another.
‘WE8ISO8859P1’ )
DUMP DUMP(‘A’) Typ=96 Len=1: Return a string value (VARCHAR2) that includes the datatype
65 code, length measured in bytes, and internal representation of a
specified expression.
 INITCAP  INITCAP(‘hi  there’) ‘Hi There’ Converts the first character in each word in a specified string to
uppercase and the rest to lowercase.
 INSTR INSTR( ‘This is a playlist’, ‘is’) 3 Search for a substring and return the location of the substring in
a string
 LENGTH LENGTH(‘ABC’) 3 Return the number of characters (or length) of a specified string
LOWER LOWER(‘Abc’) ‘abc’ Return a string with all characters converted to lowercase.
LPAD LPAD(‘ABC’,5,’*’) ‘**ABC’ Return a string that is left-padded with the specified characters to
a certain length.
LTRIM LTRIM(‘ ABC ‘) ‘ABC  ‘ Remove spaces or other specified characters in a set from the
left end of a string.
REGEXP_COUNT REGEXP_COUNT(‘1 2 3 abc’,’\d’) 3 Return the number of times a pattern occurs in a string.
REGEXP_INSTR REGEXP_INSTR( ‘Y2K problem’,’\d+’) 2 Return the position of a pattern in a string.
REGEXP_LIKE REGEXP_LIKE( ‘Year of 2017′,’\d+’ ) true Match a string based on a regular expression pattern.
REGEXP_REPLACE REGEXP_REPLACE( ‘Year of 2017′,’\d+’,  ‘Year of Dragon’ Replace substring in a string by a new substring using a regular
‘Dragon’ ) expression.
REGEXP_SUBSTR REGEXP_SUBSTR( ‘Number 10’, ‘\d+’ )  10 Extract substrings from a string using a pattern of a regular
expression.
REPLACE REPLACE(‘JACK AND JOND’,’J’,’BL’);  ‘BLACK AND Replace all occurrences of a substring by another substring in a
BLOND’ string.
RPAD  RPAD(‘ABC’,5,’*’) ‘ABC**’ Return a string that is right-padded with the specified characters
to a certain length.
RTRIM RTRIM(‘ ABC ‘) ‘ ABC’ Remove all spaces or specified character in a set from the right
end of a string.
SOUNDEX SOUNDEX(‘sea’) ‘S000’ Return a phonetic representation of a specified string.
SUBSTR SUBSTR(‘Oracle Substring’, 1, 6 ) ‘Oracle’ Extract a substring from a string.
TRANSLATE  TRANSLATE(‘12345’, ‘143’, ‘bx’)  ‘b2x5’ Replace all occurrences of characters by other characters in a
string.
TRIM TRIM(‘ ABC ‘) ‘ABC’ Remove the space character or other specified characters either
from the start or end of a string.
UPPER UPPER(‘Abc’) ‘ABC’ Convert all characters in a specified string to uppercase.
Function Example Result Description
ADD_MONTHS ADD_MONTHS( DATE '2016-02-29',  31-MAR-16 Add a number of months (n) to a date
1 ) and return the same day which is n of
months away.
CURRENT_DATE  SELECT CURRENT_DATE FROM dual   06-AUG-2017 19:43:44 Return the current date and time in the
session time zone
CURRENT_TIMESTAMP SELECT CURRENT_TIMESTAMP FROM 06-AUG-17 Return the current date and time with
dual 08.26.52.742000000 PM - time zone in the session time zone
07:00
DBTIMEZONE  SELECT DBTIMEZONE FROM dual;  -07:00 Get the current database time zone
EXTRACT EXTRACT(YEAR FROM SYSDATE)  2017 Extract a value of a date time field e.g.,
YEAR, MONTH, DAY, … from a date
time value.
FROM_TZ FROM_TZ(TIMESTAMP '2017-08-08  08-AUG-17 Convert a timestamp and a time zone to
08:09:10', '-09:00') 08.09.10.000000000 AM aTIMESTAMP WITH TIME ZONE value
-07:00
LAST_DAY LAST_DAY(DATE '2016-02-01')  29-FEB-16 Gets the last day of the month of a
specified date.
LOCALTIMESTAMP SELECT LOCALTIMESTAMP FROM dual  06-AUG-17 Return a TIMESTAMPvalue that
08.26.52.742000000 PM represents the current date and time in
the session time zone.
MONTHS_BETWEEN MONTHS_BETWEEN( DATE '2017-07- 6 Return the number of months between
01', DATE '2017-01-01' ) two dates.
NEW_TIME NEW_TIME( TO_DATE( '08-07-2017  06-AUG-2017 21:30:45 Convert a date in one time zone to
01:30:45', 'MM-DD-YYYY another
HH24:MI:SS' ), 'AST', 'PST' )
NEXT_DAY NEXT_DAY( DATE '2000-01-01',  02-JAN-00 Get the first weekday that is later than a
'SUNDAY' ) specified date.
ROUND ROUND(DATE '2017-07-16', 'MM')  01-AUG-17 Return a date rounded to a specific unit
of measure.
SESSIONTIMEZONE  SELECT SESSIONTIMEZONE FROM  -07:00 Get the session time zone
dual;
SYSDATE  SYSDATE   01-AUG-17 Return the current system date and time
of the operating system where the
Oracle Database resides.
SYSTIMESTAMP  SELECT SYSTIMESTAMP FROM dual; 01-AUG-17 Return the system date and time that
01.33.57.929000000 PM includes fractional seconds and time
-07:00 zone.
TO_CHAR  TO_CHAR( DATE'2017-01-01',  Sunday, January 01, 2017 Convert a DATE or anINTERVAL value
'DL' ) to a character string in a specified
Function Example Result Description
format.
TO_DATE TO_DATE( '01 Jan 2017', 'DD MON  01-JAN-17 Convert a date which is in the character
YYYY' ) string to a DATEvalue.
TRUNC  TRUNC(DATE '2017-07-16', 'MM')  01-JUL-17 Return a date truncated to a specific
unit of measure.
TZ_OFFSET TZ_OFFSET( 'Europe/London' )  +01:00 Get time zone offset of a time zone
name from UTC

Function Description
AVG Return the average of values of a set
COUNT Return the number of values in a set or number of rows in a table
LISTAGG Aggregate strings from multiple rows into a single string by concatenating them
MAX Return the maximum value in a set of values
MIN Return the minimum value in a set of values
SUM Returns the sum of values in a set of values

Oracle Comparison Functions

 COALESCE – show you how to substitute null with a more meaningful alternative.
 DECODE – learn how to add if-then-else logic to a SQL query.
 NVL – return the first argument if it is not null, otherwise, returns the second argument.
 NVL2 – show you how to substitute a null value with various options.
 NULLIF – return a null if the first argument equals the second one, otherwise, returns the first argument.

You might also like