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

sqlÓëhqlµÄÇø±ð

sqlÊǹØϵÊý¾Ý¿â²éѯÓïÑÔ,Ãæ¶ÔµÄÊý¾Ý¿â;
¶øhqlÊÇHibernateÕâÑùµÄÊý¾Ý¿â³Ö¾Ã»¯¿ò¼ÜÌṩµÄÄÚÖòéѯÓïÑÔ,ËäÈ»ËûÃǵÄÄ¿µÄ¶¼ÊÇΪÁË´ÓÊý¾Ý¿â²éѯÐèÒªµÄÊý¾Ý,µ«sql²Ù×÷µÄÊÇÊý¾Ý¿â±íºÍ×Ö¶Î,
¶ø×÷ΪÃæÏò¶ÔÏóµÄhql²Ù×÷µÄÔòÊdz־û¯À༰ÆäÊôÐÔ¡£
¾ÙÒ»¸ö¼òµ¥µÄÀý×Ó
sqlÓï¾ä
select * from tb_goods where id in (select goodsid from tb_getuse group by goodsid)
tb_goodsͨ¹ýgoodsidºÍtb_getuseÏà¹ØÁª£¬ÈçºÎÓÃhqlдÉÏÊösqlÓï¾ä
Èç¹ûAÊÇBµÄ¸¸±í¡£
b.A.id ÖмäµÄAÊÇB±íµÄÓ³ÉäÎļþÖжÔÓ¦µÄAµÄÃû×Ö¡£
from B as b where b.A.id in ( select a.id from A as a)


Ïà¹ØÎĵµ£º

mysql sqlÓï¾äÖеÄlimitÓ÷¨

1¡¢select * from tablename <Ìõ¼þÓï¾ä> limit 100,15
´Ó100Ìõ¼Ç¼ºó¿ªÊ¼(²»°üÀ¨µÚ100Ìõ¼Ç¼)È¡³ö15Ìõ¼Ç¼ (ʵ¼ÊÈ¡³öµÄÊÇµÚ 101-115Ìõ¼Ç¼Êý¾Ý) 
2¡¢select * from tablename <Ìõ¼þÓï¾ä> limit 15
È¡³ö Ç°15Ìõ¼Ç¼Êý¾Ý,limit 15Ï൱ÓÚ limit 0,15 ......

ʹÓÃOracle sql_trace ¹¤¾ß

Ç°ÑÔ£º
    sql_trace ÊÇÎÒÔÚ¹¤×÷Öо­³£ÒªÓõ½µÄµ÷ÓŹ¤¾ß£¬Ïà±È½Ïstatspack ÎÒ¸üÔ¸ÒâÓÃÕâ¸ö¹¤¾ß¡£
    ÒòΪÊý¾Ý¿âÂýÔ­ÒòµÄ85%ÒÔÉÏÊÇÓÉÓÚsqlÎÊÌâÔì³ÉµÄ£¬statspackûÓÐsqlµÄÖ´Ðмƻ®¡£ÏÔʾûÓÐËüÖ±¹Û£¬·½±ã£¬¶ÔÏëÒªÕë¶ÔÐÔ²»Ç¿£¬
    1£¬½éÉÜÊý¾Ý¿âµ÷ÓÅÐèÒª¾­³£»áÓõ½µÄ¹¤¾ß ......

SQL Server Ë÷Òý½á¹¹¼°ÆäʹÓã¨ËÄ£©

×÷Õߣºfreedk
Ò»¡¢ÉîÈëdz³öÀí½âË÷Òý½á¹¹
¶þ¡¢¸ÄÉÆSQLÓï¾ä
Èý¡¢ÊµÏÖСÊý¾ÝÁ¿ºÍº£Á¿Êý¾ÝµÄͨÓ÷ÖÒ³ÏÔʾ´æ´¢¹ý³Ì
¾Û¼¯Ë÷ÒýµÄÖØÒªÐÔºÍÈçºÎÑ¡Ôñ¾Û¼¯Ë÷Òý
¡¡¡¡ÔÚÉÏÒ»½ÚµÄ±êÌâÖУ¬±ÊÕßдµÄÊÇ£ºÊµÏÖСÊý¾ÝÁ¿ºÍº£Á¿Êý¾ÝµÄͨÓ÷ÖÒ³ÏÔʾ´æ´¢¹ý³Ì¡£ÕâÊÇÒòΪÔÚ½«±¾´æ´¢¹ý³ÌÓ¦ÓÃÓÚ“°ì¹«×Ô¶¯»¯”ϵͳµÄʵ¼ùÖÐʱ£¬±ÊÕß·¢ÏÖÕ ......

ÔÚJAVA Ô´³ÌÐòÖбàдSQLÓï¾äʱʹÓÃORACLE °ó¶¨±äÁ¿

ÔÚJAVAÖеÄSQL Óï¾äµÄ±àд·½Ã棬ûÓÐʹÓÃORACLE °ó¶¨±äÁ¿£¬ºÜ´ó³Ì¶ÈÉϽµµÍÁËÊý¾Ý¿âµÄÐÔÄÜ£¬±íÏÖÔÚÁ½¸ö·½Ã棺
 
1¡¢SQLÓï¾äÓ²·ÖÎö(Hard Parse)Ì«¶à£¬ÑÏÖØÏûºÄCPU×ÊÔ´£¬ÑÓ³¤ÁËSQLÓï¾ä×ܵÄÖ´ÐÐʱ¼ä
SQLÓï¾äµÄÖ´Ðйý³Ì·Ö¼¸¸ö²½Ö裺Óï·¨¼ì²é¡¢·ÖÎö¡¢Ö´ÐС¢·µ»Ø½á¹û¡£ÆäÖзÖÎöÓÖ·ÖΪӲ·ÖÎö(Hard Parse)ºÍÈí·ÖÎö(Soft Pars ......

¶¯Ì¬Ö´ÐÐsqlÓï¾ä

execute immediate Óï·¨
ºóÃæ¸úÉÏsqlÓï¾ä¿ÉÒÔ¶¯Ì¬Ö´ÐÐsqlÓï¾ä.
ʹÓó¡¾°:
(1)¼ÓÈ붯̬±í.±ÈÈçÄãÓÐÒ»ÕűíµÄÃû×Ö²»Ã÷È·,ÊÇÐèÒªÅжϵõ½µÄ,Ôò¿ÉÒÔʹÓøÃÓï·¨À´Éú³ÉsqlÓï¾ä.
(2)¼ÓÈ붯̬×Ö¶Î.Äã¸ù¾ÝÅжÏ,×îÖÕ»á¼ÓÈëͬһÕűí,µ«ÊÇÕâÕűí¸ù¾Ý²»Í¬µÄÅжÏ×ֶλáÓÐËù²»Í¬,´ËʱÈç¹ûÖ±½ÓдsqlÊǼӲ»½øÈ¥µÄ,±ØÐëʹÓö¯Ì¬sqlÓï¾ä,ÈÃo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ