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

SQLÖØ¸´¼Ç¼²éѯɾ³ý

1
¡¢²éÕÒ±íÖжàÓàµÄÖØ¸´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select

*

from
people
where
peopleId
in
(
select
   peopleId  
from
   people  
group
  
by
   peopleId  
having
  
count
(peopleId)
>

1
)
2
¡¢É¾³ý±íÖжàÓàµÄÖØ¸´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´Åжϣ¬Ö»ÁôÓÐrowid×îСµÄ¼Ç¼
delete

from
people
where
peopleId  
in
(
select
   peopleId  
from
people  
group
  
by
   peopleId   
having
  
count
(peopleId)
>

1
)
and
rowid
not

in
(
select

min
(rowid)
from
   people  
group

by
peopleId  
having

count
(peopleId )
>
1
)
3
¡¢²éÕÒ±íÖжàÓàµÄÖØ¸´¼Ç¼£¨¶à¸ö×ֶΣ©
select

*

from
vitae a
where
(a.peopleId,a.seq)
in
   (
select
peopleId,seq
from
vitae
group

by
peopleId,seq  
having

count
(
*
)
>

1
)
4
¡¢É¾³ý±íÖжàÓàµÄÖØ¸´¼Ç¼£¨¶à¸ö×ֶΣ©£¬Ö»ÁôÓÐrowid×îСµÄ¼Ç¼
delete

from
vitae a
where
(a.peopleId,a.seq)
in
   (
select
peopleId,seq
from
vitae
group

by
peopleId,seq
having

count
(
*
)
>

1
)
and
rowid
not

in
(
select

min
(rowid)
from
vitae
group

by
peopleId,seq
having

count
(
*
)
>
1
)
5
¡¢²éÕÒ±íÖжàÓàµÄÖØ¸´¼Ç¼£¨¶à¸ö×ֶΣ©£¬²»°üº¬rowid×îСµÄ¼Ç¼
select

*

from
vitae a
where
(a.peopleId,a.seq)
in
   (
select
peopleId,seq
from
vitae
group

by
peopleId,seq
having

count
(
*
)
>

1
)
and
rowid
not

in
(
select

min
(rowid)
from
vitae
group

by
peopleId,seq
having

count
(
*
)
>
1
)
(¶þ)
±È·½Ëµ
ÔÚA±íÖдæÔÚÒ»¸ö×ֶΓname”£¬
¶øÇÒ²»Í¬¼Ç¼֮¼äµÄ“name”ÖµÓпÉÄ


Ïà¹ØÎĵµ£º

PL/SQLѧϰ±Ê¼ÇÈý


1.Ìõ¼þ¿ØÖÆ
1.1 if .. then .. end if
if Ìõ¼þ then
    Óï¾ä¶Î£»
end if;
1.2 if .. then .. else .. end if
if Ìõ¼þ then
    Óï¾ä¶Î£»
else 
    Óï¾ä¶Î£»
end if;
1.3 ifǶÌ×
2.Ñ­»·¿ØÖÆ
2.1 loop .. exit .. end loop
loop  
   & ......

PL/SQLѧϰ±Ê¼ÇÆß


Oracle9iÒì³£´¦Àí·ÖΪϵͳԤ¶¨ÒåÒì³£´¦ÀíºÍ×Ô¶¨ÒåÒì³£´¦ÀíÁ½²¿·Ö¡£
×Ô¶¨ÒåÒì³£´¦Àí
1.¶¨ÒåÒì³£´¦Àí
declare Òì³£Ãû exception;
2.´¥·¢Òì³£´¦Àí
raise Òì³£Ãû
3.´¦ÀíÒì³£
exception
when Òì³£Ãû1 then
    Òì³£´¦ÀíÓï¾ä¶Î1;
when Òì³£Ãû2 then
    Òì³£´¦ÀíÓï¾ä¶Î2;
ʾÀý£º
se ......

½«Ò»¸öSQLÊý¾Ý¿âÖÐµÄ±íµ¼Èëµ½±ðÒ»¸öÊý¾Ý¿âÖÐ

µ¼ÈëµÄÏêϸÁ÷³Ì
1¡¢Ð½¨Ò»¸öÊý¾Ý¿â
2¡¢ÔÚеÄÊý¾Ý¿âÉϵãÓÒ¼ü-¡·“ËùÓÐÈÎÎñ”-¡·“µ¼ÈëÊý¾Ý¿â”£¬µãÏÂÒ»²½
3¡¢Ê²Ã´¶¼²»Òª¸Ä£¬ÔÚÊý¾Ý¿âÖÐÑ¡ÔñÄǸö¾ÉµÄÊý¾Ý¿â£¬µãÏÂÒ»²½
4¡¢ÔÚÕâ¸ö½çÃæµÄÊý¾Ý¿âÖÐÑ¡ÔñÄãн¨µÄÊý¾Ý¿â£¬µãÏÂÒ»²½
5¡¢Ñ¡Ôñ“ÔÚSQL SERVERÊý¾Ý¿âÖ®¼ä¸´ÖƶÔÏóºÍÊý¾Ý”£¬µãÏÂÒ»²½ ......

SQL*Plus FAQ

 What is SQL*Plus and where does it come from?
SQL*Plus is a command line SQL and PL/SQL language interface and reporting tool that ships with the Oracle Database Client and Server software. It can be used interactively or driven from scripts. SQL*Plus is frequently used by DBAs and Developers ......

ÔÚPHPÖÐÈ«Ãæ×èÖ¹SQL×¢Èëʽ¹¥»÷Ö®¶þ

Ò»¡¢ ×¢Èëʽ¹¥»÷µÄÀàÐÍ
¡¡¡¡¿ÉÄÜ´æÔÚÐí¶à²»Í¬ÀàÐ͵Ĺ¥»÷¶¯»ú£¬µ«ÊÇÕ§¿´ÉÏÈ¥£¬Ëƺõ´æÔÚ¸ü¶àµÄÀàÐÍ¡£ÕâÊǷdz£ÕæÊµµÄ-Èç¹û¶ñÒâÓû§·¢ÏÖÁËÒ»¸öÄܹ»Ö´Ðжà¸ö²éѯµÄ°ì·¨µÄ»°¡£±¾ÎĺóÃæ£¬ÎÒÃÇ»á¶Ô´Ë×÷ÏêϸÌÖÂÛ¡£
¡¡¡¡Èç¹ûÄãµÄ½Å±¾ÕýÔÚÖ´ÐÐÒ»¸öSELECTÖ¸ÁÄÇô£¬¹¥»÷Õß¿ÉÒÔÇ¿ÆÈÏÔʾһ¸ö±í¸ñÖеÄÿһÐмǼ-ͨ¹ý°ÑÒ»¸öÀýÈç"1=1"Õâ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ