Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
4Activity
0 of .
Results for:
No results containing your search query
P. 1
DAY2 SQL

DAY2 SQL

Ratings:

5.0

(1)
|Views: 105 |Likes:
Published by irraju

More info:

Published by: irraju on Sep 04, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

08/13/2010

pdf

text

original

 
SQL FUNCTIONS:--------------------------------------------------------ARE BUILT IN FUNCTIONS., THEY CAN BE CALLED FROM A USER DEFINED TBL OR SYSTEMDEFINED VIEW(DUAL).SQL> DESC DUAL-> DESC -> SQL*PLUS COMMAND1 COL -> DUMMY -> VARCHAR2(1)SQL> SELECT * FROM DUAL;XSYSDATE()----------------SELECT SYSDATE FROM DUAL;02-SEP-08(DEFAULT DATE FORMAT -> DD-MON-YY)SELECT SYSDATE FROM EMP;SELECT DISTINCT SYSDATE FROM EMP;TYPES:-----------NUMBERCHARACTERDATECONVERSIONMISCNUMBER:----------------ABS()SQRT()MOD()ROUND()FLOOR()CEIL()------SELECT ABS(-1),SQRT(9),MOD(3,2),ROUND(15.432), ROUND(15.432,1),ROUND(15.432,-1),FLOOR(15,432),CEIL(15.432) FROM DUAL;CHARACTER-------------------LENGTH()CONCAT()SUBSTR()INSTR()LPAD()RPAD()------LENGTH()--------------SELECT LENGTH('ANIL ANCHAN') FROM DUAL;SELECT ENAME,LENGTH(ENAME) FROM EMP;
 
CONCAT()---------------SELECT CONCAT(ENAME,JOB) WORKS_AS FROM EMP;ORSELECT ENAMEII' WORKS AS 'IIJOBII' HIS HIRDATE IS 'IIHIREDATE ASEMPLOYEE_DETAILS FROM EMP;SUBSTR()--------------SELECT ENAME,SUBSTR(ENAME,1,3) "START_1_3" FROM EMP;TRY -VE NUMBERSSELECT ENAME,SUBSTR(ENAME,3) "START_3" FROM EMP;INSTR()-----------SELECT ENAME,INSTR(ENAME,'A') "POS_A" FROM EMP;LPAD()-----------SELECT LPAD(EMPNO,10,'ORACLE') AS EMPID FROM EMP;SELECT LPAD(EMPNO,9,'ORACLE') AS EMPID FROM EMP;SELECT LPAD(EMPNO,11,'ORACLE') AS EMPID FROM EMP;SELECT LPAD(EMPNO,LENGTH(EMPNO)+6,'ORACLE') AS EMPID FROM EMP;RPAD()------------SELECT RPAD(EMPNO,LENGTH(EMPNO)+6,'ORACLE') AS EMPID FROM EMP;CONVERSION:---------------------TO_CHAR(): DATE TO CHAR FORMATTO_DATE(): DATE TO SYSDATE FORMAT----TO_CHAR():DATE TO CHAR FORMAT-----------------01-SEP-08-> SYSDATE-> DD-MON-YYINPUTOUTPUT----------------------DD02DDTH02NDYY08YYYY2008DAYTUESDAYDYTUEDyTuedaytuesdayMONSEPMONTHSEPTEMBERYEARTWO THOUSAND EIGHTHH:MI:SS10:50:07HH24:MI:SS14:55:06
 
HH:MM:SS10:09:07-- MM -> 09(SEP)WRITE A QUERY TO DISPLAY TODAY'S DAY:------------------------------------------------------------------SELECT TO_CHAR(SYSDATE,'DAY') " TODAY IS " FROM DUAL;WRITE A QUERY TO DISPLAY THE DAY OF OUR INDEPENDENCE:-----------------------------------------------------------------------------------------------47-15-08---> ????--> 'YY-DD-MM'-> 15-AUG-47TO_CHAR('15-AUG-47','DAY')SELECT TO_CHAR(TO_DATE('47-15-08','YY-DD-MM'),'DAY') "DAY OF INDEPENDENCE" FROMDUAL;SELECT TO_CHAR(TO_DATE('1947-15-08','YYYY-DD-MM'),'DAY') "DAY OF INDEPENDENCE"FROM DUAL;SELECT TO_CHAR(TO_DATE('15-AUG-1947','DD-MON-YYYY'),'DAY') "DAY OF INDEPENDENCE"FROM DUAL; --> CHECKSELECT TO_CHAR(TO_DATE('15-AUG-47'),'DAY') "DAY OF INDEPENDENCE" FROM DUAL;--> CHECKDATE FUNCTIONS: INPUT OUTPUT-----------------------------ADD_MONTHS(): SYSDATE,3-> 02-DEC-08MONTHS_BETWEEN(): 'D1' - 'D2'-> MONTHSNEXT_DAY(): SYSDATE,'FRI'-> 05-SEP-08LAST_DAY(): SYSDATE-> 30-SEP-08SELECT ADD_MONTHS(SYSDATE,3) FROM DUAL;02-DEC-08SELECT ROUND(MONTHS_BETWEEN(SYSDATE,'15-AUG-1947')/12) FROM DUAL;61SELECT NEXT_DAY(SYSDATE,'FRI') FROM DUAL;05-SEP-08SELECT LAST_DAY(SYSDATE) FROM DUAL;30-SEP-08NOTE:----------SELECT LAST_DAY(SYSDATE)+65 FROM DUAL;04-DEC-08SELECT LAST_DAY(SYSDATE+65) FROM DUAL;30-NOV-08MISC:---------NVL(): NO VALUE FNNVL2()DECODE()

Activity (4)

You've already reviewed this. Edit your review.
1 hundred reads
btmu1234 liked this
SEENIVAS liked this
betatest12 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->