Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Oracle ÈÕÆÚ/ʱ¼äµÄÏà¹Ø²Ù×÷

¡¡¡¡±¾ÎĽéÉÜÁËÔÚOracleÊý¾Ý¿âÖУ¬¶ÔÈÕÆÚ¡¢Ê±¼äµÄ¸÷ÖÖ²Ù×÷£¬°üÀ¨£ºÈÕÆÚʱ¼ä¼ä¸ô²Ù×÷¡¢ÈÕÆÚµ½×Ö·û²Ù×÷¡¢×Ö·ûµ½ÈÕÆÚ²Ù×÷¡¢trunk / ROUNDº¯ÊýµÄʹÓᢺÁÃ뼶µÄÊý¾ÝÀàÐ͵ȡ£
1.ÈÕÆÚʱ¼ä¼ä¸ô²Ù×÷
¡¡¡¡µ±Ç°Ê±¼ä¼õÈ¥7·ÖÖÓµÄʱ¼ä
¡¡¡¡select sysdate,sysdate - interval '7' MINUTE from dual
¡¡¡¡µ±Ç°Ê±¼ä¼õÈ¥7СʱµÄʱ¼ä
¡¡¡¡select sysdate - interval '7' hour from dual
¡¡¡¡µ±Ç°Ê±¼ä¼õÈ¥7ÌìµÄʱ¼ä
¡¡¡¡select sysdate - interval '7' day from dual
¡¡¡¡µ±Ç°Ê±¼ä¼õÈ¥7ÔµÄʱ¼ä
¡¡¡¡select sysdate,sysdate - interval '7' month from dual
¡¡¡¡µ±Ç°Ê±¼ä¼õÈ¥7ÄêµÄʱ¼ä
¡¡¡¡select sysdate,sysdate - interval '7' year from dual
¡¡¡¡Ê±¼ä¼ä¸ô³ËÒÔÒ»¸öÊý×Ö
¡¡¡¡select sysdate,sysdate - 8 *interval '2' hour from dual
2.ÈÕÆÚµ½×Ö·û²Ù×÷
¡¡¡¡select sysdate,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual
¡¡¡¡select sysdate,to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual
¡¡¡¡select sysdate,to_char(sysdate,'yyyy-ddd hh:mi:ss') from dual
¡¡¡¡select sysdate,to_char(sysdate,'yyyy-mm iw-d hh:mi:ss') from dual
3. ×Ö·ûµ½ÈÕÆÚ²Ù×÷
¡¡¡¡select to_date('2003-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual
¡¡¡¡¾ßÌåÓ÷¨ºÍÉÏÃæµÄto_char²î²»¶à¡£
4. trunk / ROUNDº¯ÊýµÄʹÓÃ
¡¡¡¡select trunc(sysdate ,'YEAR') from dual
¡¡¡¡select trunc(sysdate ) from dual
¡¡¡¡select to_char(trunc(sysdate ,'YYYY'),'YYYY') from dual
5.oracleÓкÁÃ뼶µÄÊý¾ÝÀàÐÍ
¡¡¡¡·µ»Øµ±Ç°Ê±¼ä ÄêÔÂÈÕСʱ·ÖÃëºÁÃë
¡¡¡¡select to_char(current_timestamp(5),'DD-MON-YYYY HH24:MI:SSxFF') from dual;
¡¡¡¡·µ»Øµ±Ç° ʱ¼äµÄÃëºÁÃ룬¿ÉÒÔÖ¸¶¨ÃëºóÃæµÄ¾«¶È(×î´ó=9)
¡¡¡¡select to_char(current_timestamp(9),'MI:SSxFF') from dual;


Ïà¹ØÎĵµ£º

OracleÖÐTO_DATE¸ñʽ

http://www.cnblogs.com/ajian/archive/2009/08/25/1421063.html
TO_DATE¸ñʽ(ÒÔʱ¼ä:2007-11-02   13:45:25ΪÀý)
  
        Year:     
        yy two digits Á½Î»Äê   &nbs ......

oracle·Ö×麯ÊýÖ®ROLLUP

 
1.³õʼ»¯ÊµÑ黵¾³
1£©´´½¨²âÊÔ±ígroup_test
sec@ora10g> create table group_test (group_id int, job varchar2(10), name varchar2(10), salary int);
¡¡
Table created.
¡¡
2£©³õʼ»¯Êý¾Ý
insert into group_test values (10,'Coding',    'Bruce',1000);
insert into group_test val ......

ORACLE¶Ô×ÖĸºÍÊý×Ö»ìºÏµÄÊý¾ÝÅÅÐò

Ö÷ÒªÊÇͨ¹ýreplaceºÍtranslateÀ´ÊµÏÖ
SQL> create view v_tt
2 as
3 select ename||' '||deptno as data
4 from emp;
View created.
SQL> select * from v_tt;
DATA
---------------------------------------------------
SMITH 20
ALLEN 30
WARD 30
JONES 20
MARTIN 30
BLAKE 30
CLARK 10
......

ROLLUPºÍCUBEÓï¾ä¡£ ORACLE·Ö×éͳ¼Æ

ROLLUPºÍCUBEÓï¾ä¡£
OracleµÄGROUP
BYÓï¾ä³ýÁË×î»ù±¾µÄÓï·¨Í⣬»¹Ö§³ÖROLLUPºÍCUBEÓï¾ä¡£Èç¹ûÊÇROLLUP(A, B, C)µÄ»°£¬Ê×ÏÈ»á¶Ô(A¡¢B¡¢C)½øÐÐGROUP
BY£¬È»ºó¶Ô(A¡¢B)½øÐÐGROUP BY£¬È»ºóÊÇ(A)½øÐÐGROUP BY£¬×îºó¶ÔÈ«±í½øÐÐGROUP BY²Ù×÷¡£Èç¹ûÊÇGROUP BY
CUBE(A, B, C)£¬ÔòÊ×ÏÈ»á¶Ô(A¡¢B¡¢C)½øÐÐGROUP
BY£¬È»ºóÒÀ´ÎÊÇ(A¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ