substr(char,m,n) |
Extracts the characters from char starting in position m for n characters. |
select substr('ABCDEF', 4, 2) from dual; |
DE |
length(char) |
Returns the length of char. |
select length('Marissa') from dual; |
7 |
rpad(expr1,n,expr2) |
Pads expr1 with expr2 to the right for n characters. Often used for space padding in the creation of a fixed length record. |
select rpad('Amanda', 10, '1') from dual; |
Amanda1111 |
initcap(char) |
Changes the first character of each element in char to uppercase. |
select initcap('shane k.') from dual; |
Shane K. |
TABLE 2-3. Common String Functions |
Table 2-4 illustrates some common numeric functions, their syntax, and the results they produce. These are only a few of the many functions available.
Function |
Action |
Example |
Displays |
ceil(n) |
Returns nearest whole number greater than or equal to n. |
select ceil(12.3) from dual; |
13 |
floor(n) |
Returns nearest whole number less than or equal to n. |
select floor(127.6) from dual; |
127 |
round(n,m) |
Rounds n to m places to the right of the decimal point. |
select round(579.34886,3) from dual; |
579.349 |
power(m,n) |
Multiplies m to the power n. |
select power(5,3) from dual; |
125 |
mod(m,n) |
Returns the remainder of the division of m by n. If n=0, then 0 is returned. If n>m, then m is returned. |
select mod(9,5) from dual; select mod(10,5) from dual; select mod(6,7) from dual; |
0 |
sqrt(n) |
Returns the square root of n. |
select sqrt(9) from dual; |
3 |
TABLE 2-4. Common Numeric Functions |