ORACLE PL/SQL¿ª·¢
¸Õ¸ÕÔÚinthirtiesÀÏ´óµÄ²©¿ÍÀï¿´µ½ÕâƪÎÄÕ£¬Ð´µÄ²»´í£¬ÕýºÃ×Ô¼º×î½üÔÚѧϰPL/SQL£¬×ª¹ýÀ´Ñ§Ï°Ñ§Ï°¡£
==================================================================================
bulk collectÊÇ¿ÉÒÔ¿´×öÊÇÒ»ÖÖÅú»ñÈ¡µÄ·½Ê½£¬ÔÚÎÒÃǵÄplsqlµÄ´úÂë¶ÎÀï¾³£×÷ΪintoµÄÀ©Õ¹À´Ê¹Ó᣶ÔÓÚselect id into v from .... ÊÇÒ»¸ö³£ÓõÄÓ÷¨¡£²»¹ýÕâÀïÖ»ÄÜÊÇ·µ»Øµ¥Ìõ¼Ç¼µÄʱºò£¬²ÅÄÜʹÓã¬Èç¹ûÊÇÓжàÌõ¼Ç¼ÎÒÃǾͲ»ÄÜÓÃÕâÑùµÄ·½Ê½£¬¶øÊÇʹÓÃfetchºÍÑ»·µÄ·½Ê½£¬²»½öʹÓÃÂé·³£¬¶øÇÒÐÔÄÜÒ²µ×Ï£¬ÕâʱÎÒÃǵÄbulk collect¡Öصdz¡ÁË£¬½â¾öÎÒÃǵÄÎÊÌâ¡£
ͨ¹ýbulk collect¿ÉÒÔ°ÑÎÒÃǵIJéѯ½á¹ûÒ»´ÎÐԵؼÓÔص½ÎÒÃǵÄǶÈë±íÖС£ÕâÑùÎÒÃDz»ÐèÒªºÜÂé·³µÄÓÃÓαêµÄÑ»·Ò»ÌõÒ»ÌõµÄÈ¥fetchß·£¬¿ÉÏë¶øÖª£¬ÕâÑù²»½ö²Ù×÷·½±ã£¬Ò²¿ÉÒÔ»ñµÃÏ൱²»´íµÄ³ÌÐòÐÔÄÜ¡£ ÎÒÃÇ¿ÉÒÔÔÚselect into, fetch into, returning intoµÄ¾ä×ÓÖÐʹÓá£ÏÂÃæÎÒÃÇͨ¹ý¶ÔÒÔÉϸ÷¸öÀý×ÓÀ´½øÐÐÑÝʾÀ´¿´¿´ËûÃǵÄÓ÷¨
ÏÈÀ´¿´¿´ÎÒÃǵIJâÊÔ±íºÍÊý¾Ý
SQL> desc test;
Name Null? Type
----------------------------------------- -------- ----------------------------
ZC_CODE VARCHAR2(20)
MONEY NUMBER(35)
MONEY_2 NUMBER(35)
SQL> col zc_code format a20;
SQL> col money format 999999.99;
SQL> col money_2 format 9999.99;
SQL>select * from test;
ZC_CODE MONEY MONEY_2
-------------------- ---------- --------
201 18600.00
20101 9600.00
2010101 3300.00
2010102 3200.00
2010103 3100.00
20102 9000.00
2010201 2000.00
2010202 7000.00
8 rows selected.
¶¨ÒåÎÒÃǵÄǶÌ×±íµÄÀàÐÍ£¬ ¶¨ÒåÔÚÒ»¸öpackageÀÕâ¸öpackageʹÎÒÃǵÄÊý¾ÝÀàÐͼ¯ºÏ
SQL> create or replace package ALL_DATA_TYPE is
2 type T_TESTROW is table of test1.test%rowtype index by binary_integer;
3 type T_TESTZCCODE is table of test1.test.zc_code%type index by binary_integer;
4 end;
5 /
ÏÈÀ´¸öselect intoµÄÀý×Ó
SQL> create or replace function test_bulkcollect return ALL_DATA_TYPE.T_TESTROW is
2 v_rtn ALL_DATA_TYPE.T_TESTROW;
3 begin
4 select * bulk collect into v_rtn from test;
5 return v_rtn;
6 end;
7 /
ͳһµÄ²âÊÔ·½·¨£¬ ÎÒÃÇ·Ö±ðÓÃÕâ¸ö²âÊÔ´úÂëÀ´ÑÝʾÒÔÉÏselect into£¬fetch in
Ïà¹ØÎĵµ£º
oracle±í¿Õ¼ä²Ù×÷Ïê½â
1
2
3×÷Õߣº À´Ô´£º ¸üÐÂÈÕÆÚ£º2006-01-04
5
6
7½¨Á¢±í¿Õ¼ä
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
¶þ¡¢ÒÔÐβεÄÐÎʽ¶¨ÒåºÍʹÓüǼ¡¢¶ÔÏóÀàÐÍ
ÔÚÓÃ×÷ÐÎʽ²ÎÊýʱ£¬¼Ç¼ÀàÐͺͶÔÏóÀàÐÍÓкܶàÏà֮ͬ´¦¡£ÔÚ½«ËüÃÇ×÷ΪÓαꡢº¯Êý»ò¹ý³ÌµÄÐÎʽ²ÎÊýÒÔÇ°£¬ÊÂÏȶ¼±ØÐ붨ÒåÒ»¸ö¼Ç¼ÀàÐÍ»òÕ߶ÔÏóÀàÐÍ¡£
ÈçÏÂÀýËùʾ£º
¼Ç¼
DECLARE
-- Define a record type.
TYPE individual_record IS RECORD
(individual_id ......
ÉÏÃæÎÒÃÇÌáµ½µÄÊÇһЩ»ù±¾µÄÌá¸ß²éѯËٶȵÄ×¢ÒâÊÂÏî,µ«ÊÇÔÚ¸ü¶àµÄÇé¿öÏÂ,ÍùÍùÐèÒª·´¸´ÊÔÑé±È½Ï²»Í¬µÄÓï¾äÒԵõ½×î¼Ñ·½°¸¡£×îºÃµÄ·½·¨µ±È»ÊDzâÊÔ£¬¿´ÊµÏÖÏàͬ¹¦ÄܵÄSQLÓï¾äÄĸöÖ´ÐÐʱ¼ä×îÉÙ£¬µ«ÊÇÊý¾Ý¿âÖÐÈç¹ûÊý¾ÝÁ¿ºÜÉÙ£¬ÊDZȽϲ»³öÀ´µÄ£¬Õâʱ¿ÉÒÔÓò鿴ִÐмƻ®£¬¼´£º°ÑʵÏÖÏàͬ¹¦ÄܵĶàÌõSQLÓï¾ä¿¼µ½²éѯ·ÖÎöÆ÷£¬°´ ......
QT DataBase SQL Explorer
1¡¢°²×°MySQLµ½¹Ù·½ÍøÕ¾ÏÂÔØMySQLÊý¾Ý¿â£¬·Ç°²×°°æ£¬Ö±½ÓÔËÐÐmysqld½ø³Ìǰ̨µÄ
2¡¢Ìí¼Óϵͳ»·¾³±äÁ¿£¬Path+=':\mysql\bin'µÄpath£¬ÔÙÔÚ¿ªÊ¼ÔËÐУ¬CMD->mysql -uroot µÇ¼µ½mySQLÊý¾Ý¿â
Default passwordûÓеģ¬ÓеĻ° mysql -uroot -pÊäÈëÃÜÂ룻ÍøÂçµÇ¼£ºmysql -h ip ......
1. SQL Óï¾äÓëSQL*Plus ÃüÁî
SQL
SQL*Plus
Ò»ÖÖÓïÑÔ
Ò»ÖÖ»·¾³
ANSI±ê×¼
Oracle µÄÌØÐÔÖ®Ò»
¹Ø¼ü×Ö²»ÄÜËõд
¹Ø¼ü×Ö¿ÉÒÔËõд
ʹÓÃÓï¾ä¿ØÖÆÊý¾Ý¿âÖеıíµÄ¶¨ÒåÐÅÏ¢
ºÍ±íÖеÄÊý¾Ý
ÃüÁî²»ÄܸıäÊý¾Ý¿âÖеÄÊý¾ÝµÄÖµ
¼¯ÖÐÔËÐÐ
2.ÒÔϼ¸¸ö²éѯºÜÖØÒª£¬×ÐϸÌå»á
1 (ÓÐÔ±¹¤µÄ³ ......