ORACLE PL/SQL ¼¯ºÏѧϰ±Ê¼Ç(Èý)
ËÄ¡¢ÁªºÏÊý×éµÄʹÓ÷½·¨
ÁªºÏÊý×éÒÔÇ°±»³ÆΪPL/SQL±í¡£ÔÚ±íÖв»ÄÜʹÓÃÁªºÏÊý×飬ֻÄܽ«ËüÃÇÓÃ×÷³ÌÐòÉè¼ÆµÄ½á¹¹Ìå¡£Ö»ÄÜÔÚPL/SQLÖзÃÎÊÁªºÏÊý×é¡£
×¢Òâµ½ÁªºÏÊý×é´øÀ´µÄһЩ¹Ø¼üÎÊÌâÊǷdz£ÖØÒªµÄ¡£ÕâЩÎÊÌâʹÎÒÃǽéÉÜËüÃǵÄÓ÷¨Ê±£¬ÐèÒª²ÉȡһЩÌرðµÄ·½·¨¡£ÕâЩÎÊÌâ°üÀ¨£º
ÁªºÏÊý×é²»ÐèÒª³õʼ»¯£¬Ò²Ã»Óй¹Ô캯ÊýÓï·¨¡£ÔÚ¶ÔËüÃǽøÐи³ÖµÒÔÇ°£¬Ò²²»ÐèҪרÃÅΪÆä·ÖÅä´æ´¢¿Õ¼ä£¬Ò²¾Í²»ÐèҪʹÓü¯ºÏAPIµÄEXTEND·½·¨¡£
ÔÚORACLE 10GÖУ¬ÒÔ¼°ÔÚORACLE 10GÒÔÇ°µÄ°æ±¾ÖУ¬¶¼¿ÉÒÔʹÓÃÊý×ÖË÷ÒýÁªºÏÊý×é¡£ÁíÍ⣬ÔÚORACLE 10GÖУ¬»¹¿ÉÒÔʹÓþßÓÐΨһÐԵı䳤×Ö·û´®×÷ΪÁªºÏÊý×éµÄË÷Òý¡£
¿ÉÒÔʹÓÃÈÎÒâµÄÕûÊý×÷ΪÁªºÏÊý×éµÄË÷Òý£¬Õâ¾Í˵Ã÷ÁªºÏÊý×éµÄË÷Òý¿ÉÒÔÊÇÈÎÒâÕýÊý¡¢¸ºÊý»ò0¡£
¿ÉÒÔÏÔʽµØ½«µÈ¼ÛµÄ%ROWTYPE¡¢¼Ç¼ÀàÐͺͶÔÏóÀàÐ͵ķµ»ØÖµ£¬×ª»»³ÉÁªºÏÊý×éµÄ½á¹¹Ìå¡£
ÁªºÏÊý×éÊÇʹÓÃFORALLÓï¾ä»òBULK COLLECT×Ó¾äµÄ¹Ø¼ü£¬¶øºóÕßÔòÔÊÐíÊý¾Ý¿âµ½³ÌÐòÉè¼Æµ¥ÔªµÄÅúת»»¡£
ÔÚʹÓÃÁËÈ«Çò»¯ÉèÖã¬ÀýÈçNLS_COMP»òNLS_SORT³õʼ»¯²ÎÊýµÄÊý¾Ý¿âÖУ¬½«×Ö·û´®ÓÃ×÷ÁªºÏÊý×éË÷ÒýµÄʱºò£¬ÐèÒªÎÒÃǽøÐÐÌØÊâµÄ´¦Àí¡£
1¡¢¶¨ÒåÁªºÏÊý×éºÍÓÃ×÷PL/SQLµÄ³ÌÐò½á¹¹Ìå
ÔÚPL/SQLÓïÑÔÖж¨ÒåÁªºÏÊý×éµÄÓï·¨ÓÐÁ½ÖÖ£¬Ò»ÖÖÊÇ£º
CREATE OR REPLACE TYPE type_name
AS TABLE OF element_type [NOT NULL]
INDEX BY [PLS_INTEGER | BINARY_INTEGER | VARCHAR2(size) ];
¿ÉÒÔ½«ÕýÊý¡¢¸ºÊý»òÕß0ÖµÓÃ×÷ÁªºÏÊý×éµÄË÷Òý¡£ORACLE 10GÖеÄPLS_INTEGERºÎBINARY_INTEGERÀàÐͶ¼ÊDz»ÊÜÏÞÖƵÄÊý¾ÝÀàÐÍ£¬ÕâÁ½¸öÊý¾ÝÀàÐͶ¼Ó³Éäµ½C/C++¡¢C#ºÍJAVAµÄµ÷Óù淶ÖС£
±ä³¤×Ö·û´®µÄ×î´ó³¤¶ÈΪ4000¸ö×Ö·û¡£
ÁíÒ»ÖÖ¶¨ÒåÁªºÏÊý×éµÄÓï·¨ÊÇ£º
CREATE OR REPLACE TYPE type_name
AS TABLE OF element_type [NOT NULL]
INDEX BY key_type;
ÆäÖеÄkey_typeÔÊÐíÎÒÃÇʹÓÃVARCHAR2¡¢STRING»òLONGÀàÐÍ¡£Ê¹ÓÃVARCHAR2ºÍSTRINGʱ£¬¶¼ÐèÒª¶¨Òå´óС¡£Ê¹ÓÃLONGÀàÐÍʱ£¬Ôò²»ÐèÒª¶¨Òå´óС£¬ÒòΪËüÊÇͨ¹ý¶¨ÒåVARCHAR£¨32760£©½øÐж¨ÒåµÄ¡£
ÁªºÏÊý×é²»ÐèÒª½øÐгõʼ»¯£¬Ò²Ã»Óй¹Ô캯ÊýÓï·¨¡£ÕâÊÇÓëÆäËûÁ½ÖÖ¼¯ºÏÀàÐÍ£¨VARRAYSºÍǶÌ×±í£©ÓÐ×ű¾ÖÊÇø±ðµÄµØ·½¡£
Èç¹ûÄãÏñÏÂÃæÕâÑù¹¹ÔìÒ»¸öÁªºÏÊý×飬ÄÇô»áÒý·¢PLS-00222Òì³£¡£
DECLARE
-- Define an associative array of strings.
TYPE card_table IS TABLE OF VARCHAR2(5 CHAR)
INDEX BY BI
Ïà¹ØÎĵµ£º
oracle±í¿Õ¼ä²Ù×÷Ïê½â
1
2
3×÷Õߣº À´Ô´£º ¸üÐÂÈÕÆÚ£º2006-01-04
5
6
7½¨Á¢±í¿Õ¼ä
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
package¾ÍÊÇÓÃÀ´·â×°¹ý³Ì£¬º¯ÊýÓõġ£
Ò»¸öpackage¿ÉÒÔ´æ·Å¶à¸ö¹ý³Ì£¬º¯Êý¡£
µ÷ÓÃÊÇ£º
°üÃû.¹ý³ÌÃû1
°üÃû.¹ý³ÌÃû2
http://hank4ever.javaeye.com/blog/472336
°ü (package)
¡¡¡¡(1)°üµÄÒâÒå
¡¡¡¡pl/sqlΪÁËÂú×ã³ÌÐòÄ£¿é»¯µÄÐèÒª,³ýÁË¿é(block)ºÍ×Ó³ÌÐò½á¹¹Íâ,»¹ÒýÈëÁË°üµÄ¹¹Ôì¡£
¡¡¡¡°üÊÇÒ»ÖÖÊý¾Ý¿â¶ÔÏó,½«Â ......
¹ØÓÚ´æ´¢¹ý³ÌºÍº¯ÊýµÄ¶¨ÒåÍøÉÏÒ»ËÑÒ»´ó°Ñ£¬ÕâÀï¾Í²»ÌØÊâ½éÉÜÁË£¬ÕâÀï¾ÍÖ»¶ÔÎÒ×Ô¼ºÐ´µÄ¼¸ÖÖ¸ñʽµÄ´æ´¢¹ý³ÌºÍº¯Êý×öһЩ×ܽᣬϣÍû¶Ô´ó¼ÒÓеã°ïÖú¡£
Ò»£º´æ´¢¹ý³Ì
1£º×îÆÕͨµÄÒ»ÖÖ¡££¨´«²Î£¬²éѯÓαִ꣬ÐУ¬Ñ»·Óαê×ö²åÈ붯×÷£©¡£
create or replace procedure zy2040_sirole(rolekey in varchar2) ......
µÚÒ»²½¡¢¼ì²é²Ù×÷ϵͳ»·¾³
rpm -q gcc make binutils openmotif glibc setarch compat-db compat-gcc-34 openmotif compat-gcc-34-c++ compat-libstdc++-33
Èç¹û¼ì²âµ½Äĸö°üûÓÐ×°£¬Ôò·Ö±ðÔÚISO¾µÏñÎļþÖÐÕÒµ½½øÐа²×°
¹ÒÔØ6ÕÅ»ò7ÕÅISOÎļþ£¬
±ÈÈç˵£ºrpm -ivh /mnt/iso/3/CentOS/openmotif*
Ö»ÒªÊÇûÓÐ×°µÄ¶¼Òª½øÐа ......
½¨±í
create table users(
id number(4) primary key,
username varchar2(10),
password varchar2(10)
)
²éѯ±í²¢½âËø±í(¼´¿ÉÒÔµã»÷ÊäÈë¿òÏÂÃæµÄ"Ëø"ͼ±ê¹¤¾ß, ¼´"Edit data")
select * from users for update
ɾ³ý±íÖжàÓàµÄÁÐ
alter table mobilephone drop column mobiletype
תÔØ
------------------- ......