oracle´æ´¢¹ý³ÌÓï·¨
oracle ´æ´¢¹ý³ÌµÄ»ù±¾Óï·¨ ¼°×¢ÒâÊÂÏî
oracle ´æ´¢¹ý³ÌµÄ»ù±¾Óï·¨
1.»ù±¾½á¹¹
CREATE OR REPLACE PROCEDURE ´æ´¢¹ý³ÌÃû×Ö
(
²ÎÊý1 IN NUMBER,
²ÎÊý2 IN NUMBER
) IS
±äÁ¿1 INTEGER :=0;
±äÁ¿2 DATE;
BEGIN
END ´æ´¢¹ý³ÌÃû×Ö
2.SELECT INTO STATEMENT
½«select²éѯµÄ½á¹û´æÈëµ½±äÁ¿ÖУ¬¿ÉÒÔͬʱ½«¶à¸öÁд洢¶à¸ö±äÁ¿ÖУ¬±ØÐëÓÐÒ»Ìõ
¼Ç¼£¬·ñÔòÅ׳öÒì³£(Èç¹ûûÓмǼÅ׳öNO_DATA_FOUND)
Àý×Ó£º
BEGIN
SELECT col1,col2 into ±äÁ¿1,±äÁ¿2 from typestruct where xxx;
EXCEPTION
WHEN NO_DATA_FOUND THEN
xxxx;
END;
...
3.IF ÅжÏ
IF V_TEST=1 THEN
BEGIN
do something
END;
END IF;
4.while Ñ»·
WHILE V_TEST=1 LOOP
BEGIN
XXXX
END;
END LOOP;
5.±äÁ¿¸³Öµ
V_TEST := 123;
6.ÓÃfor in ʹÓÃcursor
...
IS
CURSOR cur IS SELECT * from xxx;
BEGIN
FOR cur_result in cur LOOP
BEGIN
V_SUM :=cur_result.ÁÐÃû1+cur_result.ÁÐÃû2
END;
END LOOP;
END;
7.´ø²ÎÊýµÄcursor
CURSOR C_USER(C_ID NUMBER) IS SELECT NAME from USER WHERE TYPEID=C_ID;
OPEN C_USER(±äÁ¿Öµ);
LOOP
FETCH C_USER INTO V_NAME;
EXIT FETCH C_USER%NOTFOUND;
do something
END LOOP;
CLOSE C_USER;
8.ÓÃpl/sql developer debug
Á¬½ÓÊý¾Ý¿âºó½¨Á¢Ò»¸öTest WINDOW
ÔÚ´°¿ÚÊäÈëµ÷ÓÃSPµÄ´úÂë,F9¿ªÊ¼debug,CTRL+Nµ¥²½µ÷ÊÔ
¹ØÓÚoracle´æ´¢¹ý³ÌµÄÈô¸ÉÎÊÌⱸÍü
1.ÔÚoracleÖУ¬Êý¾Ý±í±ðÃû²»ÄܼÓas£¬È磺
select a.appname from appinfo a;-- ÕýÈ·
select a.appname from appinfo as a;-- ´íÎó
Ò²Ðí£¬ÊÇźÍoracleÖеĴ洢¹ý³ÌÖеĹؼü×Öas³åÍ»µÄÎÊÌâ°É
2.ÔÚ´æ´¢¹ý³ÌÖУ¬selectijһ×Ö¶Îʱ£¬ºóÃæ±ØÐë½ô¸úinto£¬Èç¹ûselectÕû¸ö¼Ç¼£¬ÀûÓÃÓαêµÄ»°¾ÍÁíµ±±ðÂÛÁË¡£
select af.keynode&nb
Ïà¹ØÎĵµ£º
±¾µØ¹ÜÀí±í¿Õ¼äÓë×Öµä¹ÜÀí±í¿Õ¼äÏà±È´ó´óÌá¸ßÁ˹ÜÀíЧÂʺÍÊý¾Ý¿âÐÔÄÜ£¬ÆäÓŵãÈçÏ£º
1.¼õÉÙÁ˵ݹé¿Õ¼ä¹ÜÀí
±¾µØ¹ÜÀí±í¿Õ¼äÊÇ×Ô¼º¹ÜÀí·ÖÅ䣬¶ø²»ÊÇÏó×Öµä¹ÜÀí±í¿Õ¼äÐèҪϵͳÀ´¹ÜÀí¿Õ¼ä·ÖÅ䣬±¾µØ±í¿Õ¼äÊÇͨ¹ýÔÚ±í¿Õ¼äµÄÿ¸öÊý¾ÝÎļþÖÐά³ÖÒ»¸öλͼÀ´¸ú×ÙÔÚ´ËÎļþÖпéµÄÊ£Óà¿Õ¼ä¼°Ê¹ÓÃÇé¿ö¡£²¢¼°Ê±×ö¸üС£ÕâÖÖ¸üÐÂÖ»¶Ô ......
oracleÊý¾Ý¿âÖÐsql»ù´¡
×÷ÕߣºØýÃû תÌù×Ô£º±¾Õ¾Ô´´ ä¯ÀÀ´ÎÊý£º21 ÎÄÕ¼È룺admin
Ò»¡¢¹ØϵÊý¾Ý¿âµÄһЩ¸ÅÄî
¡¡¡¡
¡¡¡¡1¡¢Ö÷¼üµÄÖµÒ»°ã²»¿ÉÒԸıä
¡¡¡¡
¡¡¡¡2¡¢Íâ¼ü£ºÖ¸ÏòÁíÒ»¸ö±í»ò±¾±íµÄÖ÷¼ü»òΨһ¼üµÄ×ֶΡ£Íâ¼üµÄÖµÒ»¶¨ÒªºÍijһÖ÷¼üÏàͬ ......
¹ØÓÚoracleµÄÐм¶Ëø
¡¡¡¡ÔÚoracleÖÐ,Ðм¶ËøÖ»¶ÔÓû§ÕýÔÚ·ÃÎʵÄÐнøÐÐËø¶¨¡£
¡¡¡¡Èç¹û¸ÃÓû§ÕýÔÚÐÞ¸ÄijÐУ¬ÄÇôÆäËûÓû§¾Í¿ÉÒÔ¸üÐÂͬһ±íÖиÃÐÐÖ®ÍâµÄÊý¾Ý¡£
¡¡¡¡Ðм¶ËøÊÇÒ»ÖÖÅÅËûËø£¬·ÀÖ¹ÆäËûÊÂÎñÐ޸ĴËÐУ¬µ«ÊDz»»á×èÖ¹¶ÁÈ¡´ËÐеIJÙ×÷
¡£
¡¡¡¡ÔÚʹÓÃINSERT¡¢UPDATE¡¢DELETE ºÍSELECT…FOR UPDATE µÈÓï¾äʱ ......
ORACLEÖУ¬±í¿Õ¼äÊÇÊý¾Ý¹ÜÀíµÄ»ù±¾·½·¨£¬ËùÓÐÓû§µÄ¶ÔÏóÒª´æ·ÅÔÚ±í¿Õ¼äÖУ¬Ò²¾ÍÊÇÓû§ÓпռäµÄʹÓÃȨ£¬²ÅÄÜ´´½¨Óû§¶ÔÏó£®·ñÔòÊDz»³äÐí´´½¨¶ÔÏó£¬ÒòΪ¾ÍÊÇÏë´´½¨¶ÔÏó,Èç±í,Ë÷ÒýµÈ£¬Ò²Ã»Óеط½´æ·Å,Oracle»áÌáʾ:ûÓд洢Åä¶î£®¡¡¡¡Òò´Ë£¬ÔÚ´´½¨¶ÔÏó֮ǰ£¬Ê×ÏÈÒª·ÖÅä´æ´¢¿Õ¼ä.
·ÖÅä´æ´¢£¬¾ÍÒª´´½¨±í¿Õ¼ä£º¡¡¡¡
´´½¨±í¿Õ¼äÊ ......
ÎÒÃÇÏÈÀ´¿´Ò»ÏÂËûÃǵĶ¨Ò壺
A schema is a collection of database objects (used by a user.).
Schema objects are the logical structures that directly refer to the database’s data.
A user is a name defined in the database that can connect to and access objects.
Schemas and users help database ......