DBMS
DBMS
1 .Character Functions:
Upper Returns char with all letters into upper case
Lower Converts the mixed case or uppercase character strings to lowercase
Converts the first letter of each word to upper case and remaining letters to
Initcap
lowercase
Concat Joins values together you are limited to two arguments with concat
Substr This extracts a string of determined length
Length Shows the length of a string as a numeric value
Instr Finds numeric position of named character
Lpad Pads the character value right justified
Rpad Pads the character value left justified
Trim Trims heading or trailing characters from a character string
Raplace To replace a set of character (String based)
Translate Change a character to a new described character(character based)
PROGRAM:
LENGTH('SQLFUNCTIONS')
----------------------
12
PROGRAM:
ROUND(35.823)
-------
36
TRUNC(35.823,2)
---------------
35.82
MOD(4,2)
-------------
0
CEIL(35.23)
----------- -
36
FLOOR(35.23)
------------
35
3.Date Functions:
SYSDATE is a pseudo column that returns the current date and time. When we select
sysdate it will display in a dummy table called DUAL. Oracle date range between 1 stjan
4712 BC and 31st Dec 4712 AD.
Months_between It returns the numeric value. Finds the no. of months between
date1 and date2, result may be positive or negative.
Add_months It returns the date datatype. Adds n number of calendar months
to date, n must be an integer and it can be negative
Last_day It returns the date datatype. Date of the
Next_day It returns the date datatype. Date of the next specified day of the
week following date1, char may be number representing a day,
or a character
PROGRAM:
LOWER(SYS
MONTHS_BETWEEN(SYSDATE,’12)
--------------------------------
-8.444
SQL> select months_between('01-jan-2010', sysdate) from dual;
MONTHS_BETWEEN('01-JAN-2010',SYSDATE)
-------------------------------------
-6.2451325
LAST_DAY(
---------
31-JUL-10
SQL>select next_day(sysdate, 'friday') from dual;
NEXT_DAY(
---------
09-JUL-10
SQL>select extract(day from sysdate) from dual;
EXTRACT(DAY FROM SYS
-------
12