Character/String Functions: Function Description Example
The document describes various string and character functions as well as date and time functions in Oracle SQL. Some key string functions are substr() to extract a substring, upper() and lower() to change case, and concat() to concatenate strings. Date functions include sysdate() to return the current date and time, trunc() and round() to modify dates, and add_months() to add months to a date.
Download as ODT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
27 views
Character/String Functions: Function Description Example
The document describes various string and character functions as well as date and time functions in Oracle SQL. Some key string functions are substr() to extract a substring, upper() and lower() to change case, and concat() to concatenate strings. Date functions include sysdate() to return the current date and time, trunc() and round() to modify dates, and add_months() to add months to a date.
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1
Character/String Functions
Function Description Example
Returns a portion of src starting at substr(src, p, l) substr('Hello',3,2) = 'll' position p and l char. long upper Converts to uppercase upper('Hello') = 'HELLO' lower Converts to lowercase lower('HELLO') = 'hello' initcap('HELLO, world!') = 'Hello, initcap Capitalizes the first character or each word World!' ltrim Removes blanks at the left-end of a string ltrim(' Hello ') = 'Hello ' rtrim Removes blanks at the right-end of a string rtrim(' Hello' ) = ' Hello' trim Removes blanks at either ends of a string trim(' Hello ') = 'Hello' concat Concatenates two strings concat('Hel', 'lo') = 'Hello' length Returns the length of a string length('Hello') = 5 Replaces every occurrence of x in src by y (or by replace('Hello', 'll', 'r') = 'Hero' replace(src, x, y) nothing if y is absent) replace('Hello', 'o') = 'Hell' lpad('Hello', 10, '>') = lpad(src, l, p) Returns src, left-padded to length nwith the string p '>>>>>Hello' rpad(src, l, p) Returns src, right-padded to length n with the string p rpad('Hello', 10, '!') = 'Hello!!!!!' chr Returns a character's code chr('H') = 72 soundex Computes the soundex phonetic value of a string Replaces each char. from x in srcby the corresponding translate('hello', 'hl', 'HL') = translate char. in y 'HeLLo' Same as initcap with National Language Support nls_initcap (NLS) nls_upper Same as upper with National Language Support (NLS) nls_upper('Café) = CAFÉ nls_lower Same as lower with National Language Support (NLS)
Date & Time Functions
Function Description Example sysdate Returns the current date and time Trancates a date d to the nearest time unit t(by default to the trunc(d, t) nearest day) select round(sysdate) round(d, t) As before, but using rounding from dual add_months(d, n) Returns d plus n months add_months(sysdate, 6) months_between(d1, Returns the number of months between dates d1 and d2 d2) from_tz(d, tz) Adds a timezone component tz to date d last_day(d) Returns the last day of the month containing d last_day(sysdate)