Oracle·ÖÎöº¯ÊýÓ¦ÓÃ(Analytic Functions)
Oracle ·ÖÎöº¯ÊýʹÓýéÉÜ
·ÖÎöº¯ÊýÊÇoracle816ÒýÈëµÄÒ»¸öȫеĸÅÄî,ΪÎÒÃÇ·ÖÎöÊý¾ÝÌṩÁËÒ»ÖÖ¼òµ¥¸ßЧµÄ´¦Àí·½Ê½.ÔÚ·ÖÎöº¯Êý³öÏÖÒÔÇ°,ÎÒÃDZØÐëʹÓÃ×ÔÁª²éѯ,×Ó²éѯ»òÕßÄÚÁªÊÓͼ,ÉõÖÁ¸´ÔӵĴ洢¹ý³ÌʵÏÖµÄÓï¾ä,ÏÖÔÚÖ»ÒªÒ»Ìõ¼òµ¥µÄsqlÓï¾ä¾Í¿ÉÒÔʵÏÖÁË,¶øÇÒÔÚÖ´ÐÐЧÂÊ·½ÃæÒ²ÓÐÏ൱´óµÄÌá¸ß.ÏÂÃæÎÒ½«Õë¶Ô·ÖÎöº¯Êý×öһЩ¾ßÌåµÄ˵Ã÷.
½ñÌìÎÒÖ÷Òª¸ø´ó¼Ò½éÉÜÒ»ÏÂÒÔϼ¸¸öº¯ÊýµÄʹÓ÷½·¨
1. ×Ô¶¯»ã×ܺ¯Êýrollup,cube,
2. rank º¯Êý, rank,dense_rank,row_number
3. lag,leadº¯Êý
4. sum,avg,µÄÒƶ¯Ôö¼Ó,Òƶ¯Æ½¾ùÊý
5. ratio_to_report±¨±í´¦Àíº¯Êý
6. first,lastÈ¡»ùÊýµÄ·ÖÎöº¯Êý
»ù´¡Êý¾Ý
Code:
[Copy to clipboard]
06:34:23 SQL> select * from t;
BILL_MONTH AREA_CODE NET_TYPE LOCAL_FARE
--------------- ---------- ---------- --------------
200405 5761 G 7393344.04
200405 5761 J 5667089.85
200405 5762 G 6315075.96
200405 5762 J 6328716.15
200405 5763 G 8861742.59
200405 5763 J 7788036.32
200405 5764 G &
Ïà¹ØÎĵµ£º
±¾ÊÓͼ³ÖÐø¸ú×ÙËùÓÐshared poolÖеĹ²Ïícursor£¬ÔÚshared poolÖеÄÿһÌõSQLÓï¾ä¶¼¶ÔÓ¦Ò»ÁС£±¾ÊÓͼÔÚ·ÖÎöSQLÓï¾ä×ÊԴʹÓ÷½Ãæ·Ç³£ÖØÒª¡£
V$SQLAREAÖеÄÐÅÏ¢ÁÐ
HASH_VALUE£ºSQLÓï¾äµÄHashÖµ¡£
ADDRESS£ºSQLÓï¾äÔÚSGAÖеĵØÖ·¡£
ÕâÁ½Áб»ÓÃÓÚ¼ø±ðSQLÓï¾ä£¬ÓÐʱ£¬Á½Ìõ²»Í¬µÄÓï¾ä¿ÉÄÜhashÖµÏàͬ¡£Õâʱºò£¬±ØÐëÁ¬Í¬ADDRESSÒ ......
DML:Data Manipulation Language Êý¾Ý²Ù×÷ÓïÑÔ
°üÀ¨£ºCRUD
1. insertÓï¾ä
(1) ´ÓÆäËü±íÖи´ÖÆÊý¾Ý,ʵÏÖ·½·¨:ÔÚinsert Óï¾äÖмÓÈë²éѯÓï¾ä
insert into sales_reps(id,name,salary,commission_pct) select employee_id,last_name,salary,commission_pct
from employees where job_id like '%rep';
(2) up ......
ÓÃdateÐÍ×ֶνøÐÐÊý¾Ý¼ìË÷ʱÐèҪעÒ⣺Êý¾Ý¸ñʽ»¯£¡
´ËÊý¾Ý¸ñʽ»¯²»Í¬ÓÚÓÃSimpleDateFormat("yyyy-MM-dd")¶ÔÏó½øÐиñʽ»¯£¬¶øÊÇÓÃOracleµÄÄÚÖú¯Êýto_date()
»ò±êʶ·ûdateÀ´¸ñʽ»¯¡£
ÀýÈ磺
Óиö×Ö¶ÎÊÇdateÊý¾Ý£¬ÎÒÏë²éѯijijÄê¶ÈµÄÊý¾Ý¡£
´íÎóд·¨£ºs ......
--»ñÈ¡Á½Ê±¼äµÄÏà²îºÀÃëÊý
select ceil((To_date('2008-05-02 00:00:00' , 'yyyy-mm-dd hh24-mi-ss') - To_date('2008-04-30 23:59:59' , 'yyyy-mm-dd hh24-mi-ss')) * 24 * 60 * 60 * 1000) Ïà²îºÀÃëÊý from DUAL;
/*
Ïà²îºÀÃëÊý
----------
86401000
1 row selected
*/
--»ñÈ¡Á½Ê±¼äµÄÏà²îÃëÊý
select ce ......
¾³£ÓÐͬÊÂ×ÉѯoracleÊý¾Ý¿â×Ö·û¼¯Ïà¹ØµÄÎÊÌ⣬ÈçÔÚ²»Í¬Êý¾Ý¿â×öÊý¾ÝǨÒÆ¡¢Í¬ÆäËüϵͳ½»»»Êý¾ÝµÈ£¬³£³£ÒòΪ×Ö·û¼¯²»Í¬¶øµ¼ÖÂǨÒÆʧ°Ü»òÊý¾Ý¿âÄÚÊý¾Ý±ä³ÉÂÒÂë¡£ÏÖÔÚÎÒ½«oracle×Ö·û¼¯Ïà¹ØµÄһЩ֪ʶ×ö¸ö¼òµ¥×ܽᣬϣÍû¶Ô´ó¼Ò½ñºóµÄ¹¤×÷ÓÐËù°ïÖú¡£
¡¡¡¡Ò»¡¢Ê²Ã´ÊÇoracle×Ö·û¼¯
¡¡¡¡Oracle×Ö·û¼¯ÊÇÒ»¸ö×Ö½ÚÊý¾ÝµÄ½âÊÍ ......