oracle¸ß¼¶sqlµÄ²Î¿¼×ÊÁÏ
1.¼¯ºÏ²Ù×÷
ѧϰoracleÖм¯ºÏ²Ù×÷µÄÓйØÓï¾ä£¬ÕÆÎÕunion,union all,minus,interestµÄʹÓÃ,Äܹ»ÃèÊö½áºÏÔËË㣬²¢ÇÒÄܹ»½«¶à¸ö²éѯ×éºÏµ½Ò»¸ö²éѯÖÐÈ¥£¬Äܹ»¿ØÖÆÐзµ»ØµÄ˳Ðò¡£
°üº¬¼¯ºÏÔËËãµÄ²éѯ³ÆΪ¸´ºÏ²éѯ¡£¼û±í¸ñ1-1
±í1-1
Operator Returns content
UNION ÓÉÿ¸ö²éѯѡÔñµÄËùÓв»Öظ´µÄÐÐ ²¢¼¯²»°üº¬Öظ´Öµ
UNION ALL ÓÉÿ¸ö²éѯѡÔñµÄËùÓеÄÐУ¬°üÀ¨ËùÓÐÖظ´µÄÐÐ ÍêÈ«²¢¼¯°üº¬Öظ´Öµ
INTERSECT ÓÉÿ¸ö²éѯѡÔñµÄËùÓв»Öظ´µÄÏཻÐÐ ½»¼¯
MINUS ÔÚµÚÒ»¸ö²éѯÖУ¬²»ÔÚºóÃæ²éѯÖУ¬²¢ÇÒ½á¹ûÐв»Öظ´ ²î¼¯
ËùÓеļ¯ºÏÔËËãÓëµÈºÅµÄÓÅÏȼ¶Ïàͬ£¬Èç¹ûSQLÓï¾ä°üº¬¶à¸ö¼¯ºÏÔËËã²¢ÇÒûÓÐÔ²À¨ºÅÃ÷È·µØÖ¸¶¨ÁíÒ»¸ö˳Ðò£¬Oracle·þÎñÆ÷½«ÒÔ´Ó×óµ½ÓÒµÄ˳Ðò¼ÆËã¡£ÄãÓ¦¸ÃʹÓÃÔ²À¨ºÅÀ´Ã÷È·µØÖ¸¶¨´øÁíÍâµÄ¼¯ºÏÔËËãµÄINTERSECT (Ïཻ) ÔËËã²éѯÖеĸ³ÖµË³Ðò¡£
Union all ЧÂÊÒ»°ã±Èunion¸ß¡£
1.1.unionºÍunion all
UNION(ÁªºÏ)ÔËËã
UNIONÔËËã·µ»ØËùÓÐÓÉÈÎÒ»²éѯѡÔñµÄÐС£ÓÃUNIONÔËËã´Ó¶à±í·µ»ØËùÓÐÐУ¬µ«³ýÈ¥ÈκÎÖظ´µÄÐС£
ÔÔò :
􀂃±»Ñ¡ÔñµÄÁÐÊýºÍÁеÄÊý¾ÝÀàÐͱØÐëÊÇÓëËùÓÐÓÃÔÚ²éѯÖеÄSELECTÓï¾äÒ»Ö¡£ÁеÄÃû×Ö²»±ØÏàͬ¡£
􀂃ÁªºÏÔËËãÔÚËùÓб»Ñ¡ÔñµÄÁÐÉϽøÐС£
􀂃ÔÚ×öÖظ´¼ì²éµÄʱºò²»ºöÂÔ¿Õ(NULL)Öµ¡£
􀂃INÔËËãÓбÈUNIONÔËËã¸ßµÄÓÅÏȼ¶¡£
􀂃ÔÚĬÈÏÇé¿öÏ£¬Êä³öÒÔSELECT×Ó¾äµÄµÚÒ»ÁеÄÉýÐòÅÅÐò¡£
È«ÁªºÏ(UNION ALL)ÔËËã
ÓÃÈ«ÁªºÏÔËËã´Ó¶à¸ö²éѯÖзµ»ØËùÓÐÐС£
ÔÔò
􀂃ºÍÁªºÏ²»Í¬£¬Öظ´µÄÐв»±»¹ýÂË£¬²¢ÇÒĬÈÏÇé¿öÏÂÊä³ö²»ÅÅÐò¡£
􀂃²»ÄÜʹÓÃDISTINCT¹Ø¼ü×Ö¡£
ʹÓãº
Select statement union | union all Select statement;
1.2.intersect½»¼¯²Ù×÷
ÏཻÔËËã
ÓÃÏཻÔËËã·µ»Ø¶à¸ö²éѯÖÐËùÓеĹ«¹²ÐС£ ÎÞÖظ´ÐС£
ÔÔò
􀂃ÔÚ²éѯÖÐ
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
Ê×ÏÈ£¬Ô ......
--±äÁ¿¸³Öµ
declare
identity :=0;
a varchar2(59,0);
b varchar2(50):='abc';
a :='cba';
-- ¿ØÖÆÓï¾ä
----------------------------------
if a>b then
  ......
´ó¿é£¬Óŵ㣺
1¡¢Ë³Ðò¶Á¡¢Ë÷Òý¶ÁÐÔÄܺÃ
ÒòΪ´ó¿éÈÝÄɵÄÐÐÏà¶ÔС¿éÊý¾Ý
¶à£¬ÔÚ½øÐÐÈ«±íɨÃèµÄʱºò£¬»òÕßË÷ÒýɨÃèµÄʱºò£¬ËùÐèÒªµÄÎïÀí¶Á¡¢Âß¼¶Á¶¼ÒªÉÙ¡£
ËüÒ²ÄܼõСË÷ÒýµÄÊ÷¸ß¡£¶ÔÓÚË÷Òý·ÃÎÊ
µÄÐÔÄÜÓÐËùÌá¸ß¡£
2¡¢´ó¿éÄÜÈÝÄɱȽϴóµÄÐÐ
ÈÝÄÉ´óÐиöÈËÀí½â£¬Ò»¶¨³Ì¶ÈÉÏ¿ÉÒÔ±ÜÃâÐÐǨÒÆ¡¢ÐÐÁ´½Ó¡£¼õС´óÐеĶÁÈ¡¿é ......
¶¯Ì¬ÍøÒ³¿ª·¢——ASPÁ¬½ÓSQL2005Êý¾Ý¿â
˵Ã÷£ºa¡¢ÒÔÏÂ×Ö·ûÖÐÊý¾Ý¿âÃûforum£¬Êý¾Ý¿â·þÎñÆ÷ÃûWWW-2443D34E558\SQL2005£¨»òÕß127.0.0.1£©
b¡¢²é¿´sqlÊý¾Ý¿â·þÎñÆ÷Ãû³Æ£º¶ÔÏó×ÊÔ´¹ÜÀíÆ÷->Êý¾Ý¿â->ÓÒ¼üµã»÷×Ô¼º½¨µÄÊý¾Ý¿â->ÊôÐÔ->ȨÏÞ
c¡¢Provider=sqlncliÒ²¿ÉÒÔ,UIDÓë“=”Ö®¼ä²»¿ÉÒÔ ......