Escolar Documentos
Profissional Documentos
Cultura Documentos
Character functions
� Lower
� Upper
� ASCII
� CHR
� INITCAP
� LENGTH
� LTRIM
� RTRIM
� TRIM
� RPAD
� LPAD
� SOUNDEX
� CONCAT
� INSTR
� SUBSTR
� ||
Lpad and Rpad: To �pad� the right or left side of a column with any set of
characters. The character set can be anything: spaces, periods, commas, letters or
numbers, pound signs (#), or even exclamation marks (!).
Length: Length tells how long a string is i.e. how many characters it has in it,
including letters, spaces, and anything else.
Instr: The INSTR function allows for simple or sophisticated searching through a
string for a set of characters
CHR and ASCII: The ASCII and CHR functions are used during ad hoc queries. CHR
converts numeric values to their ASCII character String equivalents.
Select CHR (65)|| CHR (80)|| CHR (80)|| CHR (76)|| CHR (69)
from DUAL;
SOUNDEX: This is a one string function that is used almost exclusively in WHERE
clause. It has the unusual ability to find words that sound like other
Words, regardless of how either is spelled.
Date functions
� SYSDATE
� CURRENT_DATE
� SYSTIMESTAMP
� ADD_MONTHS (date, count)
� CURRENT_TIMESTAMP
� GREATEST (date1, date2, date3�)
� LEAST (date1, date2, date3�)
� LAST_DAY (date)
� MONTHS_BETWEEN (date2, date1)
� NEXT_DAY (date, �day�)
� TO_CHAR (date, �format�)
� TO_TIMESTAMP (�value�)
DUAL: DUAL is a small but useful Oracle table created for testing
Functions or doing quick calculations.
ERROR:
Interval year to month and Interval day to second data types are mostly used
During statically analysis and data mining.
� Numeric functions
� ABS
� CEIL
� FLOOR
� POWER
� ROUND
� TRUNC
� SQRT
� SIGN
� NVL
SUM
AVG
COUNT
MAX
MIN
SELECT SUM(SAL)
FROM EMP;
SELECT AVG(SAL),SUM(COMM)
FROM EMP;
SELECT MAX(SAL),SUM(COMM),MIN(SAL)
FROM EMP;
SELECT COUNT(*),COUNT(EMPNO),COUNT(COMM)
FROM EMP;
SELECT DEPTNO,SUM(SAL),MAX(SAL),MIN(SAL)
FROM EMP
GROUP BY DEPTNO
SELECT JOB,SUM(SAL),MAX(SAL),MIN(SAL)
FROM EMP
GROUP BY JOB
HAVING JOB IN ('CLERK','ANALYST')
Dual:
it is the default table provided by the oracle to the user where the user
can check the functions can select all psedo cols where it has one row and one
column called dummy numeric functions
sum abs(-200)
sin() cos()
tan()
select round(89.8789) from dual;
select round(89.8789,2) from dual;
select trunc(89.879) from dual;
character functions
upper()
lower()
Date functions:
To char (sysdate,'day') where the user can retrieve in user defined ways
To char (sysdate,'dd')
To char (sysdate,'dd/month/yyyy')
To char (sysdate,'dd/mon/yy')
To char (sysdate,'ddth-mm-yy')
Select to char(hiredate , 'ddth\yyyy\month') from emp to_date