PL/SQLѧϰ±Ê¼Ç
1£®SQL²¢Ðвéѯ
alter session enable parallel dml execute immediate 'alter session enable parallel dml'; --Ð޸ĻỰ²¢ÐÐDML select /*+parallel(a,4)*/ * from table_name a select /*+parallel(a,8)*/ * from table_name a select /*+parallel(a,4) parallel(b,4) parallel(c,4)*/ a.*,b.*,c.* from table_name1 a,table_name2 b,table_name c insert /*+parallel(t,4)*/ into table_name t insert /*+parallel(t,8)*/ into table_name t /*+parallel(t,8)*/ ²¢Ðд¦Àí£¬Ò»°ãΪCPUµÄ±¶ÊýÈ磺4£¬8µÈ,ÔÚÖ´ÐÐÀàÐÍSQL±ØÐëÏÈÔËÐÐ:alter session enable parallel dml
2£®É¾³ý±í·ÖÇøÊý¾Ý
alter table masamk.tb_mk_sc_user_mon truncate partition mk_user_mon_'||trim(iv_month) ɾ³ýÖ¸¶¨±í·ÖÇøÊý¾Ý
3£®minus(²î¼¯)Óëintersect(½»¼¯)
minus Ö¸ÁîÊÇÔËÓÃÔÚÁ½¸ö SQL Óï¾äÉÏ¡£ËüÏÈÕÒ³öµÚÒ»¸ö SQL Óï¾äËù²úÉúµÄ½á¹û£¬È»ºó¿´ÕâЩ½á¹ûÓÐûÓÐÔÚµÚ¶þ¸ö SQL Óï¾äµÄ½á¹ûÖÐ,Èç¹ûÓеĻ°£¬ÄÇÕâÒ»±Ê×ÊÁϾͱ»È¥³ý£¬¶ø²»»áÔÚ×îºóµÄ½á¹ûÖгöÏÖ; Èç¹ûµÚ¶þ¸ö SQL Óï¾äËù²úÉúµÄ½á¹û²¢Ã»ÓдæÔÚÓÚµÚÒ»¸ö SQL Óï¾äËù²úÉúµÄ½á¹ûÄÚ£¬ÄÇÕâ±Ê×ÊÁϾͱ»Å×Æú¡£ intersect Ö¸ÁîÊÇÔËÓÃÔÚÁ½¸öSQLÓï¾äÉÏ£¬Èç¹ûÁ½¸öSQLÓï¾äµÄ¼Ç¼ÍêÈ«ÏàͬÔòÏÔʾÏàÓ¦¼Ç¼£¬·ñÔò½«²»ÔÚ½á¹ûÖгöÏÖ
4£®Order by ÖÐµÄ nulls last
order by area_code,bill_month nulls last --nulls last ½«ÅÅÐò×Ö¶ÎΪnull¼Ç¼·ÅÔÚ×îºóÃæ
5£®nvlµÄ¼¸¸ö²»Í¬º¯Êý
nvl(a,1) Èç¹û a Ϊ null ·µ»Ø 1,·ñÔò·µ»Ø a nvl2(a,1,0) Èç¹û a Ϊ null ·µ»Ø 0,·ñÔò·µ»Ø 1 nullif(a,b) Èç¹û a = b ·µ»Ø null ,·ñÔò·µ»Ø a
6£®ÔõÑùÈ·±£×
Ïà¹ØÎĵµ£º
ms sqlÖеÄintÐÍĬÈÏÊÇ4룬mysqlµÄintÐÍĬÈÏÊÇ11λ£¬Ç°Õßµ½ºóÕßµÄÒÆÖ²²»»áÓÐʲôÒþ»¼£¬µ«ÊǺóÕßµ½Ç°ÕßµÄÒÆÖ²¾Í´æÔÚλÊý²»¹»£¬²»ÄÜ´æ´¢´óÊýµÄÒþ»¼¡£
»¹ÓÐbigint£¬ms sqlÊÇ8룬mysqlĬÈÏÊÇ20λ¡£ ......
ÊÂÎñÈÕÖ¾½áβ¾³£Ìá½»Êý¾Ý¿âδ±¸·ÝµÄÊÂÎñÈÕÖ¾ÄÚÈÝ¡£»ù±¾ÉÏ£¬Ã¿Ò»´ÎÄãÖ´ÐÐÊÂÎñÈÕÖ¾±¸·Ýʱ£¬Ä㶼ÔÚÖ´ÐÐÊÂÎñÈÕÖ¾½áβµÄ±¸·Ý¡£
ÄÇΪʲô»áÕâôÉè¼ÆÄØ£¿ÒòΪҲÐíÓÉÓÚ½éÖʵÄË𻵣¬µ±Êý¾Ý¿âÒѾ²»ÔÙ¿ÉÓÃʱ£¬Âé·³¾ÍÀ´ÁË¡£Èç¹ûÏÂÒ»¸öÂß¼²½ÖèÕýºÃ¾ÍÊÇÒª±¸·Ýµ±Ç°ÊÂÎñÈÕÖ¾µÄ»°£¬¿ÉÒÔÓ¦ÓÃÕâ¸ö±¸·ÝÀ´Ê¹Êý¾Ý¿â´¦Óڵȴý(Standby)״̬¡£ÄãÉ ......
1.
select top m * from tablename where id not in (select top n id from tablename)
2.
select top & ......
ÔÚ Oracle 10g ÖÐ
¿ÉÒÔͨ¹ý http://localhost:5560/isqlplus ·ÃÎÊ isqlplus
ÔÚ isqlplus ÖÐ ¿ÉÒÔÖ´ÐÐ plsql
set serveroutput on size 100000 // ´ò¿ª ·þÎñÆ÷µÄÊä³ö on ºóÃæÊÇ »º´æµÄ´óС ·¶Î§ÊÇ (2000 ÖÁ 1000000)
begin
dbms_output.put_line('hel ......
´Ó2000¿ªÊ¼¾ÍÊÇMS SQL¼ÒµÄÖÒʵÓû§ÁË£¬2000µÄʱºòÎÒÊÇ´ÓÒ»±¾2000±¦µä¿ªÊ¼ÈëÃŵģ¬´Ó2000µ½2005¾ÀúÁ˺ܳ¤Ê±¼ä£¬ºÜ¶àµÄÓû§ÖÁ½ñ»¹ËÀËÀµÄÊØ×Å2000£¬Èç¹û²»Êǹ¤³ÌÒªÇ󣬹À¼ÆÎÒÒ²²»»áÖ÷¶¯»»µ½2005£¬È»¶øÑÛ¾¦Ò»Õ££¬2008ÓÖ³öÀ´ÁË£¬°§Ì¾£¬2005µÄ¹¦ÄÜÎÒ¶¼Ã»ÓÐÃþ͸ÄØ¡£
2008Óë2005µÄ¶Ô±È
1.Âý£¬Ê²Ã´¶¼Âý£¬´Ó»Ö¸´Êý¾Ý¿â£¬µ½µ¼ÈëÊý¾Ý ......