oracleÖÐintervalµÄÓ÷¨
oracle ÖÐµÄ interval Êý¾ÝÀàÐÍÓÃÓÚÌåÏÖʱ¼ä¾àÀ룬Ó﷨Ϊ interval £¬¿ÉʹÓüӼõ³Ë³ýÔËËã²Ù×÷ interval£¬ÊÊÓÃÓڴ洢ʱ¼äÊý¾Ý¡¢ÅÌËãÈÕÆÚ²îÖµµÈ³¡¾°¡£
Oracle ÖÐ INTERVAL µÄÓ÷¨
ÔÚ Oracle ÖУ¬INTERVAL Êý¾ÝÀàÐÍÓÃÓÚÌåÏÖʱ¼ä¾àÀë¡£ËüºÜÊÇÊʺϴ洢ºÍ²Ù×÷ʱ¼äÊý¾Ý¡£
INTERVAL µÄÓï·¨
INTERVAL
µÇ¼ºó¸´ÖÆ
ÆäÖУº
¾«¶È ÊÇ INTERVAL ÖµµÄСÊýλÊý¡£
µ¥Î» ָ׼ʱ¼ä¾àÀëµÄµ¥Î»£¬¿ÉÒÔÊÇ£º
YEAR£ºÄê
MONTH£ºÔÂ
DAY£ºÈÕ
HOUR£ºÊ±
MINUTE£º·Ö
SECOND£ºÃë
YEAR TO MONTH£ºÄêµ½ÔÂ
DAY TO HOUR£ºÌ쵽ʱ
DAY TO MINUTE£ºÌìµ½·Ö
DAY TO SECOND£ºÌìµ½Ãë
½¨Éè INTERVAL
¿ÉÒÔʹÓÃÒÔÏÂÓï·¨½¨Éè INTERVAL£º
CAST( AS INTERVAL )
µÇ¼ºó¸´ÖÆ
ÀýÈ磺
CAST('1' AS INTERVAL YEAR) -- ½¨ÉèÒ»¸ö¾àÀë 1 ÄêµÄÖµ CAST('-2' AS INTERVAL MONTH) -- ½¨ÉèÒ»¸ö¾àÀë 2 ¸öÔµĸºÖµ
µÇ¼ºó¸´ÖÆ
²Ù×÷ INTERVAL
¿ÉÒÔʹÓÃËãÊõÔËËã·û¶Ô INTERVAL ¾ÙÐвÙ×÷£º
¼Ó·¨ (+)£ºÔöÌíʱ¼ä¾àÀë¡£
¼õ·¨ (-)£º¼õСʱ¼ä¾àÀë¡£
³Ë·¨ (*)£º½«Ê±¼ä¾àÀë³ËÒÔÒ»¸öÊý×Ö¡£
³ý·¨ (/)£º½«Ê±¼ä¾àÀë³ýÒÔÒ»¸öÊý×Ö¡£
ÀýÈ磺
INTERVAL '1' YEAR + INTERVAL '3' MONTH -- ÔöÌíÒ»¸öʱ¼ä¾àÀ룬¾àÀëΪ 1 Äê 3 ¸öÔ INTERVAL '2' DAY - INTERVAL '1' DAY -- ¼õСһ¸öʱ¼ä¾àÀ룬¾àÀëΪ 1 Ìì 3 * INTERVAL '1' HOUR -- ½«Ê±¼ä¾àÀë³ËÒÔ 3£¬¾àÀëΪ 3 Сʱ INTERVAL '1' DAY / 2 -- ½«Ê±¼ä¾àÀë³ýÒÔ 2£¬¾àÀëΪ 12 Сʱ
µÇ¼ºó¸´ÖÆ
ʹÓà INTERVAL
INTERVAL ¿ÉÓÃÓÚÐí¶àÓÃ;£¬°üÀ¨£º
´æ´¢ºÍ²Ù×÷ʱ¼äÊý¾Ý¡£
ÅÌËãÈÕÆÚºÍʱ¼äÖ®¼äµÄ²îÖµ¡£
½¨Éè»ùÓÚʱ¼äµÄ´¥·¢Æ÷»òÔ¼Êø¡£
ÒÔÉϾÍÊÇoracleÖÐintervalµÄÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡