Oracle ϵÁУºPL/SQL±í
Oracle ϵÁУº PL/SQL±í
Ò»£¬Ê²Ã´ÊÇPL/SQL±í£¿
Ê×ÏÈPL/SQL±íºÍ¼Ç¼(Record)Ò»Ñù£¬¶¼ÊǸ´ºÏÊý¾ÝÀàÐÍ¡£¿ÉÒÔ¿´×öÊÇÒ»ÖÖÓû§×Ô¶¨ÒåÊý¾ÝÀàÐÍ¡£
PL/SQL±íÓɶàÁе¥ÐеıêÁ¿¹¹³ÉµÄÁÙʱË÷Òý±í¶ÔÏó¡£×é³ÉÀàËÆÓÚһάÊý×é¡£
Çø±ðºÍÁªÏµ¼Ç¼(Record)µÄµ¥ÐжàÁкÍÎïÀí´æ´¢Êý¾ÝµÄ±í¡£
Record + PL/SQL±í¿ÉÒÔ½øÐÐÊý¾ÝµÄ¶àÐжàÁд洢¡£
ÉúÃüÖÜÆÚÔÚ³ÌÐò¿éÄÚ¡£
¶þ£¬PL/SQL±íµÄ×é³É½á¹¹
PL/SQL±íÖ»ÓÐÁ½ÁÐ,ÆäÖеÚÒ»ÁÐΪË÷ÒýÁÐΪIntegerÀàÐÍË÷ÒýÁУ¬9iºó¿ÉÒÔÖ§³Ö×Ö·ûË÷Òý¡£µÚ¶þÁÐΪÓû§×Ô¶¨ÒåÁУ¬ÉùÃ÷Óû§¿ÉÓÃÁÐÀàÐÍ.
ͨ¹ýË÷ÒýÁÐÖеÄË÷ÒýÖµÀ´²Ù×÷PL/SQL±íÖжÔÓ¦µÄÓû§×Ô¶¨ÒåÁС£ÀàËÆÓÚ¼üÖµ¶Ô¡£
È·±£Ë÷ÒýÖµµÄΨһÐÔ¡£Èç¹ûË÷ÒýÖµÖظ´²»»á±¨´í£¬»á¸²¸ÇÇ°ÃæµÄÖµ¡£
Èý£¬ÈçºÎ´´½¨ºÍʹÓÃPL/SQL±í£¿
¢ÙÉùÃ÷PL/SQL±íÀàÐͶÔÏó
Óï·¨£º
TYPE PL/SQL±íÃû IS TABLE OF ¿ÉÓÃÁÐÀàÐÍ [NOT NULL]
INDEX BY BINARY_INTEGER;
¿ÉÓÃÁÐÀàÐÍ¿ÉÒÔΪOracleµÄÊý¾ÝÀàÀàÐÍÒÔ¼°Óû§×Ô¶¨ÒåÀàÐÍ;
ÊôÐÔ·½·¨:
count --·µ»Øpl/sql±íµÄ×ÜÐÐÊý£»
delect --ɾ³ýpl/sql±íµÄËùÓÐÄÚÈÝ£»
delect(ÐÐÊý) --ɾ³ýpl/sql±íµÄÖ¸¶¨µÄÐУ»
delct(¿ªÊ¼ÐУ¬½áÊøÐÐ) --ɾ³ýpl/sql±íµÄ¶àÐУ»
first --·µ»Ø±íµÄµÚÒ»¸öINDEX;
next(ÐÐÊý) --Õâ¸öÐÐÊýµÄÏÂÒ»ÌõµÄINDEX;
last --·µ»Ø±íµÄ×îºóÒ»¸öINDEX;
¢ÚÉùÃ÷PL/SQL±íÀàÐͱäÁ¿£º
Óï·¨£º
PL/SQL±íÀàÐͱäÁ¿Ãû PL/SQL±íÀàÐÍ£»
¢ÛÊý¾ÝÌî³äºÍ·ÃÎÊ
Óï·¨£º
PL/SQL±íÀàÐͱäÁ¿Ãû(Ë÷ÒýÁÐÖµ) := Ìî³äÉùÃ÷ÀàÐÍÖµ£»
PL/SQL±íÀàÐͱäÁ¿Ãû.ÊôÐÔ·½·¨Ãû£»
Àý×Ó£º
Declare
Type MyTabType Is Table Of VarChar2(10) Index By Binary_Integer;
MyTab MyTabType;
vN Number(4);
Begin
MyTab(1) := 'A';
MyTab(2) := 'B';
MyTab(3) := 'C'; --¸²¸ÇÇ°ÃæË÷ÒýֵΪ3¶ÔÓ¦µÄÁÐÖµB
vN := MyTab.First;
DBMS_OUTPUT.PUT_LINE(
Ïà¹ØÎĵµ£º
ÓÉÓÚÒÔÇ°¶¼ÊÇÔÚsqlserver 2005´¦Àí£¬ÏÖÔÚ¿Í»§ÒªÇóoracleÊý¾Ý¿â·þÎñÆ÷£¬
×î³õµÄ´úÂëΪ£º
allRecordSize = (Integer) rs1.getObject(1); //Integer allRecordSize=0;
µ±Ö´ÐеÄʱºò±¨£ºBigDecimalÎÞ·¨×ª»¯ÎªIntegerÀàÐÍ
ΪÁ˼æÈÝÁ½ÕßÐ޸ĺóµÄ´úÂëΪ£º
Object o = rs1.getObject(1);
&nbs ......
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......
µ±Ç°Èκΰ汾µÄORACLE¿Í»§¶ËÔÚÈκΰ汾µÄWINDOWS7É϶¼²»ÄÜÕý³£Íê³É°²×°¡£
Ö÷ÒªÊÇÒòΪORACLE°²×°µÄÏȾöÌõ¼þÀï²Ù×÷ϵͳ°æ±¾²»·ûºÏ£¬µ«ÊÇÕâ¸öÒÉÎÊ¿ÉÒÔÐÞ¸Ärefhost.xml´¦Àí£¬ ¾ßÌåÊÇÔÚrefhost.xmlÖÐÌí¼Ó
<!--Microsoft Windows 7-->
<OPERATING_SYSTEM>
& ......
Oracle 10g statisticÊý¾Ýͳ¼Æ,Oracle»á¸ù¾ÝÕâЩͳ¼ÆÐÅÏ¢À´¾ö¶¨ÊÇ×ßRBO(Rule-BasedOptimization)£¬»¹ÊÇ×ßCBO(Cost-BasedOptimization)£¬»áȥѡÔñÄÄÖÖÖ´Ðмƻ®¸ü»®Ëã,Ó°ÏìÊÇ·ñ×ßÏà¹ØµÄË÷ÒýµÈ.Èç¹ûÊÇCBOµÄ»°£¬ËüÒÀ¿¿×¼È·µÄ£¨»òÕß˵±È½Ï׼ȷµÄ£©Í³¼ÆÐÅÏ¢À´²úÉúÓÅ»¯µÄÖ´Ðз¾¶,Èç¹ûûÓÐ×ö¹ýͳ¼Æ£¬CBOÒ²¾ÍûÓÐ×öcostÆÀ¹ÀµÄÒÀ¾Ý ......
Oracle ´¥·¢Æ÷ÓÐÓï¾ä¼¶´¥·¢Æ÷ºÍÐм¶´¥·¢Æ÷
Óï¾ä¼¶´¥·¢Æ÷ µ±É¾³ý²¿ÃűíÖеIJ¿ÃźÅʱ£¬Í¬Ê±É¾³ýµôÔ±¹¤±íÖв¿ÃźÅΪ£ºold.deptnoµÄ¼Ç¼
create or replace trigger del_dept_id
after delete on dept
for each row
begin
delete from emp where deptno=:old.deptno;
end;
µ±Íù²¿Ãűí²åÈëʱ£¬Í¬Ê±ÔÚÔ±¹¤±íÖ ......