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

ͨ¹ý·ÖÎöSQLÓï¾äµÄÖ´Ðмƻ®ÓÅ»¯SQL(Èý)

ËÄ£ºORACLEµÄÓÅ»¯Æ÷
ÓÅ»¯Æ÷ÓÐʱҲ±»³ÆΪ²éѯÓÅ»¯Æ÷£¬ÕâÊÇÒòΪ²éѯÊÇÓ°ÏìÊý¾Ý¿âÐÔÄÜ×îÖ÷ÒªµÄ²¿·Ö£¬²»ÒªÒÔΪֻÓÐSELECTÓï¾äÊDzéѯ¡£Êµ¼ÊÉÏ£¬´øÓÐÈκÎWHEREÌõ¼þµÄDML(INSERT¡¢UPDATE¡¢DELETE)Óï¾äÖж¼°üº¬²éѯҪÇó£¬ÔÚºóÃæµÄÎÄÕÂÖУ¬µ±Ëµµ½²éѯʱ£¬²»Ò»¶¨Ö»ÊÇÖ¸SELECTÓï¾ä£¬Ò²ÓпÉÄÜÖ¸DMLÓï¾äÖеIJéѯ²¿·Ö¡£ÓÅ»¯Æ÷ÊÇËùÓйØϵÊý¾Ý¿âÒýÇæÖеÄ×îÉñÃØ¡¢×ÌôÕ½ÐԵIJ¿¼þÖ®Ò»£¬´ÓÐÔÄܵĽǶȿ´Ò²ÊÇ×îÖØÒªµÄ²¿·Ö£¬ËüÐÔÄܵĸߵÍÖ±½Ó¹Øϵµ½Êý¾Ý¿âÐÔÄܵĺûµ¡£
ÎÒÃÇÖªµÀ£¬SQLÓï¾äͬÆäËüÓïÑÔ(ÈçCÓïÑÔ)µÄÓï¾ä²»Ò»Ñù£¬ËüÊǷǹý³Ì»¯(non-procedural)µÄÓï¾ä£¬¼´µ±ÄãҪȡÊý¾Ýʱ£¬²»ÐèÒª¸æËßÊý¾Ý¿âͨ¹ýºÎÖÖ;¾¶È¥È¡Êý¾Ý£¬Èçµ½µ×ÊÇͨ¹ýË÷ÒýÈ¡Êý¾Ý£¬»¹ÊÇÓ¦¸Ã½«±íÖеÄÿÐÐÊý¾Ý¶¼È¡³öÀ´£¬È»ºóÔÙͨ¹ýÒ»Ò»±È½ÏµÄ·½Ê½È¡Êý¾Ý(¼´È«±íɨÃè)£¬ÕâÊÇÓÉÊý¾Ý¿âµÄÓÅ»¯Æ÷¾ö¶¨µÄ£¬Õâ¾ÍÊǷǹý³Ì»¯µÄº¬Ò壬Ҳ¾ÍÊÇ˵£¬ÈçºÎÈ¡Êý¾ÝÊÇÓÉÓÅ»¯Æ÷¾ö¶¨£¬¶ø²»ÊÇÓ¦Óÿª·¢Õßͨ¹ý±à³Ì¾ö¶¨¡£ÔÚ´¦ÀíSQLµÄSELECT¡¢UPDATE¡¢INSERT»òDELETEÓï¾äʱ£¬Oracle ±ØÐë·ÃÎÊÓï¾äËùÉæ¼°µÄÊý¾Ý£¬OracleµÄÓÅ»¯Æ÷²¿·ÖÓÃÀ´¾ö¶¨·ÃÎÊÊý¾ÝµÄÓÐЧ·¾¶£¬Ê¹µÃÓï¾äÖ´ÐÐËùÐèµÄI/OºÍ´¦Àíʱ¼ä×îС¡£
ΪÁËʵÏÖÒ»¸ö²éѯ£¬Äں˱ØÐëΪÿ¸ö²éѯ¶¨ÖÆÒ»¸ö²éѯ²ßÂÔ£¬»òΪȡ³ö·ûºÏÌõ¼þµÄÊý¾ÝÉú³ÉÒ»¸öÖ´Ðмƻ®(execution plan)¡£µäÐ͵ģ¬¶ÔÓÚͬһ¸ö²éѯ£¬¿ÉÄÜÓм¸¸öÖ´Ðмƻ®¶¼·ûºÏÒªÇ󣬶¼Äܵõ½·ûºÏÌõ¼þµÄÊý¾Ý¡£ÀýÈ磬²ÎÓëÁ¬½ÓµÄ±í¿ÉÒÔÓжàÖÖ²»Í¬µÄÁ¬½Ó·½·¨£¬ÕâÈ¡¾öÓÚÁ¬½ÓÌõ¼þºÍÓÅ»¯Æ÷²ÉÓõÄÁ¬½Ó·½·¨¡£ÎªÁËÔÚ¶à¸öÖ´Ðмƻ®ÖÐÑ¡Ôñ×îÓŵÄÖ´Ðмƻ®£¬ÓÅ»¯Æ÷±ØÐëʹÓÃһЩʵ¼ÊµÄÖ¸±êÀ´ºâÁ¿Ã¿¸öÖ´Ðмƻ®Ê¹ÓõÄ×ÊÔ´(I/0´ÎÊý¡¢CPUµÈ)£¬ÕâЩ×ÊÔ´Ò²¾ÍÊÇÎÒÃÇËù˵µÄ´ú¼Û(cost)¡£Èç¹ûÒ»¸öÖ´Ðмƻ®Ê¹ÓõÄ×ÊÔ´¶à£¬ÎÒÃǾÍ˵ʹÓÃÖ´Ðмƻ®µÄ´ú¼Û´ó¡£ÒÔÖ´Ðмƻ®µÄ´ú¼Û´óС×÷ΪºâÁ¿±ê×¼£¬ÓÅ»¯Æ÷Ñ¡Ôñ´ú¼Û×îСµÄÖ´Ðмƻ®×÷ΪÕæÕýÖ´ÐиòéѯµÄÖ´Ðмƻ®£¬²¢Å×ÆúÆäËüµÄÖ´Ðмƻ®¡£
ÔÚORACLEµÄ·¢Õ¹¹ý³ÌÖУ¬Ò»¹²¿ª·¢¹ý2ÖÖÀàÐ͵ÄÓÅ»¯Æ÷£º»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ºÍ»ùÓÚ´ú¼ÛµÄÓÅ»¯Æ÷¡£Õâ2ÖÖÓÅ»¯Æ÷µÄ²»Í¬Ö®´¦¹Ø¼üÔÚÓÚ£ºÈ¡µÃ´ú¼ÛµÄ·½·¨ÓëºâÁ¿´ú¼ÛµÄ´óС²»Í¬¡£ÏÖ¶ÔÿÖÖÓÅ»¯Æ÷×öһϼòµ¥µÄ½éÉÜ£º
»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ -- Rule Based (Heuristic) Optimization(¼ò³ÆRBO)£º
ÔÚORACLE7֮ǰ£¬Ö÷ÒªÊÇʹÓûùÓÚ¹æÔòµÄÓÅ»¯Æ÷¡£ORACLEÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖвÉÓÃÆô·¢Ê½µÄ·½·¨(Heuristic Approach)»ò¹æÔò(Rules)À´Éú³ÉÖ´Ðмƻ®¡£ÀýÈ磬Èç¹ûÒ»¸ö²éѯµÄwhereÌõ¼þ(where clause)°üº¬Ò»¸öν´Ê(predicat


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

oracle Ò»ÌõsqlÉú³É10WÌõ²âÊÔÊý¾Ý

×öÊý¾Ý¿â¿ª·¢»ò¹ÜÀíµÄÈ˾­³£Òª´´½¨´óÁ¿µÄ²âÊÔÊý¾Ý£¬¶¯²»¶¯¾ÍÐèÒªÉÏÍòÌõ£¬Èç¹ûÒ»ÌõÒ»ÌõµÄ¼È룬ÄÇ»áÀË·Ñ´óÁ¿µÄʱ¼ä£¬±¾ÎĽéÉÜÁËOracleÖÐÈçºÎͨ¹ýÒ»ÌõSQL¿ìËÙÉú³É´óÁ¿µÄ²âÊÔÊý¾ÝµÄ·½·¨¡£
²úÉú²âÊÔÊý¾ÝµÄSQLÈçÏ£º
SQL> select rownum as id,
  2          &nbs ......

SQL CASEµÄÓ÷¨£¬±ÈÏëÏóÖеÄÇ¿´ó

±íÈçÏÂ
Ò»ÌõÓï¾äÏÔʾËùÓдóÓÚ25ËêºÍϵÄÈË£¬ÒÔÉϵÄÈËÏÔ'´óÁä'
select case when age>25 then '´óÁä' else 'СÁä' end as ÄêÁ伶±ð,count(*) as ÈËÊý from infor group by case when age>25 then '´óÁä' else 'СÁä' end
  ......

MS SQL Server ¡¢Sybase¡¢ OracleÖ§³ÖËø¶¨·½°¸µÄ²»Í¬

»¹ÊǼ¸Î»¶ÁÎÒµÄÊé (¡¶Oracle´óÐÍÊý¾Ý¿âϵͳÔÚAIX UNIXÉϵÄʵսÏê½â¡·) µÄ¶ÁÕßÀ´Óʼþ×ÉѯÎÊÌ⣬ºÜ±§Ç¸ÎÒ²»ÄÜÖðλ»Ø¸´Óʼþ£¬µÚÒ»ÎÒÕæµÄͦ棬µÚ¶þÕâЩÎÊÌâÆÄÓй²ÐÔ¡£ÎÒÀ´½èÖúÕâ¸öµØ·½£¬Í³Ò»µØºÍÖîλ̽ÌÖ£¬ºÜ¶àÎÊÌâÎÒÒ²ÊÇÔÚÃþË÷ÖУ¬²»ÄÜÖ±½Ó¸ø´ó¼Ò´ð°¸£¬ºÇºÇ£¬´ó¼Ò¼ûÁ°¡!

˵˵ËøÎÊÌâ¡£ MS SQLÖ§³ÖµÄËøÀàÐͺÍOracle²îÒìÊǺ ......

ͨ¹ý·ÖÎöSQLÓï¾äµÄÖ´Ðмƻ®ÓÅ»¯SQL(¶þ)


¶þ£ºÓÐЧµÄÓ¦ÓÃÉè¼Æ
ÎÒÃÇͨ³£½«×î³£ÓõÄÓ¦Ó÷ÖΪ2ÖÖÀàÐÍ£ºÁª»úÊÂÎñ´¦ÀíÀàÐÍ(OLTP)£¬¾ö²ßÖ§³Öϵͳ(DSS)¡£
Áª»úÊÂÎñ´¦Àí(OLTP)
¸ÃÀàÐ͵ÄÓ¦ÓÃÊǸßÍÌÍÂÁ¿£¬²åÈë¡¢¸üС¢É¾³ý²Ù×÷±È½Ï¶àµÄϵͳ£¬ÕâЩϵͳÒÔ²»¶ÏÔö³¤µÄ´óÈÝÁ¿Êý¾ÝΪÌØÕ÷£¬ËüÃÇÌṩ¸ø³É°ÙÓû§Í¬Ê±´æÈ¡£¬µäÐ͵ÄOLTPϵͳÊǶ©Æ±ÏµÍ³£¬ÒøÐеÄÒµÎñϵͳ£¬¶©µ¥ÏµÍ³¡£OT ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ