oracleÈÕÆÚ´¦ÀíÍêÈ«°æ(תÔØ)
TO_DATE¸ñʽ
Day:
dd number 12
dy abbreviated fri
day spelled out friday
ddspth spelled out, ordinal twelfth
Month:
mm number 03
mon abbreviated mar
month spelled out march
Year:
yy two digits 98
yyyy four digits 1998
24Сʱ¸ñʽÏÂʱ¼ä·¶Î§Îª£º 0:00:00 - 23:59:59....
12Сʱ¸ñʽÏÂʱ¼ä·¶Î§Îª£º 1:00:00 - 12:59:59 ....
1.
ÈÕÆÚºÍ×Ö·ûת»»º¯ÊýÓ÷¨£¨to_date,to_char£©
2.
select to_char( to_date(222,'J'),'Jsp') from dual
ÏÔʾTwo Hundred Twenty-Two
3.
ÇóijÌìÊÇÐÇÆÚ¼¸
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day') from dual;
ÐÇÆÚÒ»
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual;
monday
ÉèÖÃÈÕÆÚÓïÑÔ
ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN';
Ò²¿ÉÒÔÕâÑù
TO_DATE ('2002-08-26', 'YYYY-mm-dd', 'NLS_DATE_LANGUAGE = American')
4.
Á½¸öÈÕÆÚ¼äµÄÌìÊý
select floor(sysdate - to_date('20020405','yyyymmdd')) from dual;
5. ʱ¼äΪnullµÄÓ÷¨
select id, active_date from table1
UNION
select 1, TO_DATE(null) from dual;
×¢ÒâÒªÓÃTO_DATE(null)
6.
a_date between to_date('20011201','yyyymmdd') and to_date('20011231','yyyymmdd')
ÄÇô12ÔÂ31ºÅÖÐÎç12µãÖ®ºóºÍ12ÔÂ1ºÅµÄ12µã֮ǰÊDz»°üº¬ÔÚÕâ¸ö·¶Î§Ö®Äڵġ£
ËùÒÔ£¬µ±Ê±¼äÐèÒª¾«È·µÄʱºò£¬¾õµÃto_char»¹ÊDZØÒªµÄ
7. ÈÕÆÚ¸ñʽ³åÍ»ÎÊÌâ
ÊäÈëµÄ¸ñʽҪ¿´Äã°²×°µÄORACLE×Ö·û¼¯µÄÀàÐÍ, ±ÈÈç: US7ASCII, date¸ñʽµÄÀàÐ;ÍÊÇ: '01-Jan-01'
alter system set NLS_DATE_LANGUAGE = American
alter session set NLS_DATE_LANGUAGE = American
»òÕßÔÚto_dateÖÐд
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual;
×¢ÒâÎÒÕâÖ»ÊǾÙÁËNLS_DATE_LANGUAGE£¬µ±È»»¹Óкܶ࣬
¿É²é¿´
select * from nls_session_parameters
select * from V$NLS_PARAMETERS
8.
select count(*)
from ( select rownum-1 rnum
from all_objects
where rownum <= to_date('2002-02-28','yyyy-mm-dd') - to_date('2002-
02-01','yyyy-mm-dd')+1
)
where to_char( to_date('2002-02-01','yyyy-mm-dd')+rnum-1, 'D' )
not
in ( '1', '7' )
Ïà¹ØÎĵµ£º
1.LOWER(str) Ç¿ÖÆСд
2.UPPER(str) Ç¿ÖÆ´óд
3.INITCAP(str) ÿ¸öµ¥´ÊÊ××Öĸ´óд
ʾÀý£º
SQL> select initcap('my_boy') from dual; --·µ»Ø"My_Boy"
×¢Ò⣺µ¥´ÊÖ®¼äÓÃÏ»®Ïߣ¨"_"£©·Ö¸î
4.CONCAT(str1,str2£©Á¬½Óº¯Êý,Á¬½Óstr1ºÍstr2×Ö·û´®
5.SUBSTR(string,a[,b])·µ»ØstringµÄÒ»²¿·Ö£¬aºÍbÒÔ×Ö·ûΪµ¥Î»¡£´Ó× ......
µ±Ö´ÐвåÈëµÈ²Ù×÷ʱ³öÏÖ´íÎóÌáʾ“unable to extand table ……” £¬Ôò˵Ã÷¸Ã±íËùÔÚ±í¿Õ¼ä¿Õ¼ä²»×ãÁË¡£
Èç¹ûÊÇÔÚwinserverÏÂÔòΪ±í¿Õ¼äÔö¼ÓÎļþ¼´¿É£¨±¾ÎIJ»×ö½éÉÜ£©¡£
±¾ÎÄÖ÷Òª½éÉÜÊý¾Ý¿â·þÎñÆ÷»·¾³ÎªAIXʱ£¬ÈçºÎΪ±í¿Õ¼äÔö¼ÓÂãÉ豸¡£
͉˕
°üº¬AIXϵͳ´æ´¢¹ÜÀíµÄ»ù±¾½éÉÜ£»
AIXͨ¹ýÈý¸ö²ã´Î¶Ô ......
RAW£¬ÀàËÆÓÚCHAR£¬ÉùÃ÷·½Ê½RAW(L)£¬LΪ³¤¶È£¬ÒÔ×Ö½ÚΪµ¥Î»£¬×÷ΪÊý¾Ý¿âÁÐ×î´ó2000£¬×÷Ϊ±äÁ¿×î´ó32767×Ö½Ú¡£
¡¡¡¡LONG RAW£¬ÀàËÆÓÚLONG£¬×÷ΪÊý¾Ý¿âÁÐ×î´ó´æ´¢2G×Ö½ÚµÄÊý¾Ý£¬×÷Ϊ±äÁ¿×î´ó32760×Ö½Ú
¡¡¡¡½¨±í²Ù×÷:
¡¡¡¡create table raw_test (id number, raw_date raw(10));
¡¡¡¡²åÈërawÊý¾Ý²Ù×÷:
¡¡¡¡insert into raw ......
Ò»¡¢ Êý¾Ý¿â ORACLE
ËäÈ»ÕâЩÌâÄ¿¶¼¿ÉÒÔGµ½£¬µ«»¹ÊÇÒª¿¼²ìÒ»ÏÂÄúÏÖÔڵij£Ì¬Ë®Æ½£¬£º£©
T±í£º£¨×ֶΣºID£¬NAME£¬ADDRESS£¬PHONE£¬LOGDATE£©
E±í£º£¨×ֶΣºNAME£¬ADDRESS£¬PHONE£©
1£® ½«±íTÖеÄ×Ö¶ÎLOGDATEÖÐΪ2001-02-11µÄÊý¾Ý¸üÐÂΪ2003-01-01£¬Çëд³öÏàÓ¦µÄSQLÓï¾ä¡££¨¸Ã×Ö¶ÎÀàÐÍΪÈÕÆÚÀàÐÍ£©
2£® Çëд³ö½«±íTÖÐNAME ......