ORACLE to_char(),to_date()Ó÷¨
to_date() function
1.ÈÕÆÚ¸ñʽ²ÎÊý º¬Òå˵Ã÷
D Ò»ÖÜÖеÄÐÇÆÚ¼¸
DAY ÌìµÄÃû×Ö£¬Ê¹ÓÿոñÌî³äµ½9¸ö×Ö·û
DD ÔÂÖеĵڼ¸Ìì
DDD ÄêÖеĵڼ¸Ìì
DY ÌìµÄ¼òдÃû
IW ISO±ê×¼µÄÄêÖеĵڼ¸ÖÜ
IYYY ISO±ê×¼µÄËÄλÄê·Ý
YYYY ËÄλÄê·Ý
YYY,YY,Y Äê·ÝµÄ×îºóÈý룬Á½Î»£¬Ò»Î»
HH Сʱ£¬°´12Сʱ¼Æ
HH24 Сʱ£¬°´24Сʱ¼Æ
MI ·Ö
SS Ãë
MM ÔÂ
Mon Ô·ݵļòд
Month Ô·ݵÄÈ«Ãû
W ¸ÃÔµĵڼ¸¸öÐÇÆÚ
WW ÄêÖеĵڼ¸¸öÐÇÆÚ
2.ÈÕÆÚʱ¼ä¼ä¸ô²Ù×÷
µ±Ç°Ê±¼ä¼õÈ¥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
to_char() function
The following are number examples for the to_char function.
to_char(1210.73, '9999.9')
would return '1210.7'
to_char(1210.73, '9,999.99')
would return '1,210.73'
to_char(1210.73, '$9,999.00')
would return '$1,210.73'
to_char(21, '000099')
would return '000021'
The following is a list of valid parameters when the to_char function is used to convert a date to a string. These parameters can be used in many combinations.
Parameter
Explanation
YEAR
Year, spelled out
YYYY
4-digit year
YYY
YY
Y
Last 3, 2, or 1 digit(s) of year.
IYY
IY
I
Last 3, 2, or 1 digit(s) of ISO year.
IYYY
4-digit year £â£á£ó£åd on the ISO standard
Q
Quarter of year (1, 2, 3, 4; JAN-MAR = 1).
MM
Month (01-12; JAN = 01).
MON
Abbreviated name of month.
MONTH
Name of month, padded with blanks to length of 9 characters.
RM
Roman numeral month (I-XII; JAN = I).
WW
Week of year (1-53) where week 1 starts on
Ïà¹ØÎĵµ£º
oracle±í¿Õ¼ä²Ù×÷Ïê½â
1
2
3×÷Õߣº À´Ô´£º ¸üÐÂÈÕÆÚ£º2006-01-04
5
6
7½¨Á¢±í¿Õ¼ä
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
ÐÇÆÚÒ» ·¢ÏÖÒ»¸ö±íÓкܶàÖØ¸´Êý¾Ý Ëæ»úʹÓÃɾ³ýÖØ¸´Êý¾ÝµÄÓï¾ä¡£
ÐÇÆÚ¶þ ·¢ÏÖ ÕâÓï¾äÅÜÁ˺ܾö¼Ã»ÅÜÍ꣬13¸öСʱÁË£¡Ö»²»¹ýɾ³ý10¸öÔµÄÊý¾Ý¶øÒÑ
ÒÀÈ»¶ÏÁËËü£¬¿ÉËü»Ø¹ö»¨ÁË4¸öСʱ£¬ÉÏÎçÓ°ÏìÁËÊý¾Ý¿âµÄ·þÎñËÙ¶ÈÁË¡£
È»ºóÒ»¸öÔÂÒ»¸öÔ¼ì²éÖØ¸´Êý¾ÝµÄ·¶Î§£¬×îºó¶¨Î»µ½9Ôµ½10Ô¡£É¾³ýËü£¬ÓÃÄÇÌõÓï¾äºÜÂý£¬Ò»¸öСʱºó ......
µ¥±íÊý¾ÝÇ¨ÒÆ£ºÖ§³Öclob,blob
exp estarcom/estarcom@ORACLE tables=AA direct=y file=C:/AAA1.dmp
¡¡¡¡ imp estarcom/estarcom@ORACLE tables=AA file=C:/AAA1.dmp fromuser=estarcom touser=estarcom
È«¿âÊý¾ÝÇ¨ÒÆ
exp userid=zhongxin/zhongxin@ORACLE own ......
oracleµÄnvlº¯ÊýµÄÓ÷¨ ͨ¹ý²éѯ»ñµÃij¸ö×ֶεĺϼÆÖµ£¬Èç¹ûÕâ¸öֵλnull½«¸ø³öÒ»¸öÔ¤ÉèµÄĬÈÏÖµ
select nvl(sum(t.dwxhl),1) from tb_jhde t where zydm=-1ÕâÀï¹ØÐĵÄnvlµÄÓ÷¨£¬nvl£¨arg,value£©´ú±íÈç¹ûÇ°ÃæµÄargµÄֵΪnullÄÇô·µ»ØµÄֵΪºóÃæµÄvalue
Èç: NVL(a,b)¾ÍÊÇÅжÏaÊÇ·ñÊÇNULL,Èç¹û²»ÊÇ·µ»ØaµÄÖµ£¬Èç¹ ......