Oracle select in/exists/not in/not exits
in ÊÇ°ÑÍâ±íºÍÄÚ±í×÷hash Á¬½Ó£¬¶øexistsÊǶÔÍâ±í×÷loopÑ»·£¬Ã¿´ÎloopÑ»·ÔÙ¶ÔÄÚ±í½øÐвéѯ¡£
Ò»Ö±ÒÔÀ´ÈÏΪexists±ÈinЧÂʸߵÄ˵·¨ÊDz»×¼È·µÄ¡£
Èç¹û²éѯµÄÁ½¸ö±í´óСÏ൱£¬ÄÇôÓÃinºÍexists²î±ð²»´ó¡£
in ÊÇ°ÑÍâ±íºÍÄÚ±í×÷hash Á¬½Ó£¬¶øexistsÊǶÔÍâ±í×÷loopÑ»·£¬Ã¿´ÎloopÑ»·ÔÙ¶ÔÄÚ±í½øÐвéѯ¡£
Ò»Ö±ÒÔÀ´ÈÏΪexists±ÈinЧÂʸߵÄ˵·¨ÊDz»×¼È·µÄ¡£
Èç¹û²éѯµÄÁ½¸ö±í´óСÏ൱£¬ÄÇôÓÃinºÍexists²î±ð²»´ó¡£ Èç¹ûÁ½¸ö±íÖÐÒ»¸ö½ÏС£¬Ò»¸öÊÇ´ó±í£¬Ôò×Ó²éѯ±í´óµÄÓÃexists£¬×Ó²éѯ±íСµÄÓÃin£º ÀýÈ磺±íA£¨Ð¡±í£©£¬±íB£¨´ó±í£©
1£º
select * from A where cc in (select cc from B)
ЧÂʵͣ¬Óõ½ÁËA±íÉÏccÁеÄË÷Òý£»
select * from A where exists(select cc from B where cc=A.cc)
ЧÂʸߣ¬Óõ½ÁËB±íÉÏccÁеÄË÷Òý¡£
Ïà·´µÄ
2£º
select * from B where cc in (select cc from A)
ЧÂʸߣ¬Óõ½ÁËB±íÉÏccÁеÄË÷Òý£»
select * from B where exists(select cc from A where cc=B.cc)
ЧÂʵͣ¬Óõ½ÁËA±íÉÏccÁеÄË÷Òý¡£
not in ºÍnot exists
Èç¹û²éѯÓï¾äʹÓÃÁËnot in ÄÇôÄÚÍâ±í¶¼½øÐÐÈ«±íɨÃ裬ûÓÐÓõ½Ë÷Òý£»
¶ønot extsts µÄ×Ó²éѯÒÀÈ»ÄÜÓõ½±íÉϵÄË÷Òý¡£
ËùÒÔÎÞÂÛÄǸö±í´ó£¬ÓÃnot exists¶¼±Ènot inÒª¿ì¡£ in Óë =µÄÇø±ð select name from student where name in ('zhang','wang','li','zhao'); Óë select name from student where name='zhang' or name='li' or name='wang' or name='zhao' µÄ½á¹ûÊÇÏàͬµÄ¡£
-----------------------------------------------------------------ʵÀý
--µÇ½gather/123456@pc150 Ö´ÐÐÒÔÏÂÓï¾ä£¬×¢ÒâÖ´ÐÐʱ¼ä
---С±í
er_street_code
select distinct tt.gkdm from er_street_code tt where tt.gkdm is not null
---´ó±í
er_in_detail,er_reck_detail ---Àý1
select * from er_reck_detail t1 where t1.gkdm in (select gg.gkdm from er_street_code gg) select * from er_reck_detail t1 where exists (select * from er_street_code gg where t1.gkdm=gg.gkdm) ---Àý2
select * from er_street_code aa where aa.gkdm in (select mm.gkdm from er_reck_detail mm) select * from er_street_code aa where exists (select * from er_reck_detail
Ïà¹ØÎĵµ£º
ÈçºÎÐÞ¸ÄOracleĬÈÏÓû§ÃÜÂëÓÐЧÆÚʱ¼ä
1¡¢²é¿´Óû§µÄproifleÊÇÄĸö£¬Ò»°ãÊÇdefault£º
sql>SELECT username,PROFILE from dba_users;
2¡¢²é¿´Ö¸¶¨¸ÅÒªÎļþ£¨Èçdefault£©µÄÃÜÂëÓÐЧÆÚÉèÖãº
sql> SELECT * from dba_profiles s WHERE
  ......
ʲôÊÇsavepoint?
Use the SAVEPOINT statement to identify a point in a transaction to which you can later roll back.
¸øÄã¸öÀý×Ó
SQL> create table test (id number(7));
±íÒÑ´´½¨¡£
SQL> insert into test values (3);
ÒÑ´´½¨ 1 ÐС£
SQL> savepoint a;
±£´æ ......
1£¬segments µÄ·ÖÀà
l
Êý¾Ý¶Î
l
Ë÷Òý¶Î
l
ÁÙʱ¶Î
l
»ØÍË ......
sqlldrÏê½â
Oracle µÄSQL*LOADER¿ÉÒÔ½«ÍⲿÊý¾Ý¼ÓÔص½Êý¾Ý¿â±íÖС£ÏÂÃæÊÇSQL*LOADERµÄ»ù±¾Ìص㣺
1£©ÄÜ×°È벻ͬÊý¾ÝÀàÐÍÎļþ¼°¶à¸öÊý¾ÝÎļþµÄÊý¾Ý
2£©¿É×°Èë¹Ì¶¨¸ñʽ£¬×ÔÓɶ¨½çÒÔ¼°¿É¶È³¤¸ñʽµÄÊý¾Ý
3£©¿ÉÒÔ×°Èë¶þ½øÖÆ£¬Ñ¹ËõÊ®½øÖÆÊý¾Ý
4£©Ò»´Î¿É¶Ô¶à¸ö±í×°ÈëÊý¾Ý
5£©Á¬½Ó¶à¸öÎïÀí¼Ç¼װµ½Ò»¸ö¼Ç¼ÖÐ
6£©¶ÔÒ ......