Oracle 10g ÒªµãÕûÀí Ö® PL/SQL
PL/SQL
1 ¸ÅÊö
PL/SQLÊÇÒ»ÖÖ¹ý³Ì»¯±à³ÌÓïÑÔ£¬Óû§¿ÉÒÔʹÓÃPL/SQL±àд¹ý³Ì¡¢º¯Êý¡¢³ÌÐò°ü¡¢´¥·¢Æ÷²¢ÇÒ´æ´¢ÕâЩ´úÂë¡£
PL/SQL²»Çø·Ö´óСд¡£
PL/SQL·ÖΪ¼¸²¿·Ö£º
declare ¿ÉÑ¡ ÉùÃ÷²¿·Ö
-----±äÁ¿£¬Óα꣬Óû§¶¨ÒåµÄÒì³£
begin Ö´Ðв¿·Ö
-----SQLÓï¾ä
-----PL/SQLÓï¾ä
exception ¿ÉÑ¡ Òì³£´¦Àí²¿·Ö
-----µ±´íÎó·¢Éúʱ×öºÎ´¦Àí
end ½áÊø
2 PL/SQL³ÌÐò±êʶ·û
PL/SQLÖеıêʶ·û¶¨ÒåΪ×ÖĸÊý×ֽṹ£¬ÓÐÈçÏÂÏÞÖÆ
¢Ù ±êʶ·û²»Äܳ¬¹ý30¸ö×Ö·û
¢Ú µÚÒ»¸ö×Ö·û±ØÐëÊÇ×Öĸ
¢Û ²»·Ö´óСд
¢Ü ²»ÄÜÓüõºÅ
¢Ý ²»ÄÜÊÇSQL±£Áô×Ö
3 PL/SQL³ÌÐòÔËËã·û
µÈÓÚ =
²»µÈÓÚ <> != ~=
¸³ÖµºÅ £º=
×Ö·ûÁ¬½Ó·û ||
¿ÕÖµ is null
×¢ÊÍ £¨µ¥ÐУ©—£¨¼õºÅ£©
£¨¶àÐУ©/* */
4 PL/SQL³ÌÐòÊý¾ÝÀàÐÍ
£¨1£©×Ö·ûÊý¾ÝÀàÐÍ
×ʹÓãºchar£¨×Ö½Ú³¤¶È£©£¬varchar2£¨×Ö½Ú³¤¶È£©
£¨2£©ÊýÖµÊý¾ÝÀàÐÍ
×ʹÓãºnumber£¨³¤¶È£¬¾«¶
Ïà¹ØÎĵµ£º
oracle±í¿Õ¼ä²Ù×÷Ïê½â
1
2
3×÷Õߣº À´Ô´£º ¸üÐÂÈÕÆÚ£º2006-01-04
5
6
7½¨Á¢±í¿Õ¼ä
8
9CREATE TABLESPACE data01
10DATAFILE '/ora ......
oracle½«×Ö·û´®×ª»»Îª12СʱÓë24СʱÖÆ£º
--12СʱÖÆ£º
select hsv.mydate from huhai_seq_value hsv
where hsv.mydate = to_date('2009-03-03 00:00:00','yyyy-mm-dd hh:mi:ss');
--24СʱÖÆ£º
select hsv.mydate from huhai_seq_value hsv
where hsv.mydate = to_date('2009-03-03 00:00:00','yyyy-m ......
ÔÚJ2EEÓ¦ÓóÌÐò¿ª·¢ÖУ¬Ó¦ÓóÌÐòÓëÊý¾Ý¿âÁ¬½ÓµÄ½¨Á¢ÊÇÎÒÃǾ³£Óöµ½µÄÎÊÌâÖ®Ò»¡£ÔÚÕâÀïÎÒÖ÷Ҫ̸̸ÔÚ±¾µØÓ¦ÓóÌÐòÖÐͨ¹ýOCI·½Ê½¡¢thin·½Ê½ºÍJdbcOdbcÇÅ·½Ê½Á¬½ÓOracleÊý¾Ý¿â£¬ÔÚiPlanet Application Server 6.5ºÍSun ONE Application Server 7ÖжÔOracleÊý¾Ý¿âÁ¬½Ó³ØµÄÅäÖÃÒÔ¼°Ó¦ÓÃÖÐÈçºÎ´ÓÁ¬½Ó³ØÖлñµÃÁ¬½Ó¡£
Ò»¡¢±¾µØͨ¹ýJ ......
¹ÜÀí±í
±íÊÇÕæÕý´æ´¢ÐÅÏ¢µÄ¶ÔÏó¡£
1 Êý¾ÝÀàÐÍ
£¨1£©ÊýÖµÀàÐÍ£ºÓÃÓÚ´æ´¢ÕûÊý¡¢¸¡µãÊý¡¢ÊµÊý¡£
number£¨¾«¶È£¬·¶Î§£©¾«¶ÈÊÇÖ¸Êý×Ö¸öÊý×ܺͣ¬·¶Î§ÊÇָСÊýµãÓұߵÄλÊý¡£
£¨2£©×Ö·ûÀàÐÍ£ºÉùÃ÷°üº¬ÁË×Öĸ¡¢Êý×ÖÊý¾ÝµÄÁС£
char£º´æ´¢¹Ì¶¨³¤¶È×Ö·û´®
&n ......
¹ÜÀí°²È«ÐÔ
1 Oracle±êʾ·û
¢Ù²»ÊDZ£Áô×Ö
¢Ú1~30¸ö×Ö·û
¢ÛÖ»ÄÜÊÇ×ÖĸºÍ#¡¢$¡¢_
¢Ü²»ÄÜ°üº¬µ¥ÒýºÅºÍË«ÒýºÅ
2 Óû§
ÔÚOracleÖУ¬Êý¾Ý¿âÓû§ºÍģʽÊÇ°²È«µÄ×î»ù±¾µ¥Ôª¡£
£¨1£©Óû§ºÍģʽ
Êý¾Ý¿âģʽ¶¨ÒåΪÊý¾Ý¿â¶ÔÏóµÄ¼¯ºÏ£¬¶øģʽµÄÃû³Æ¾ÍÊÇÓµÓлò¿ØÖÆÕâЩÊý¾Ý¿â¶ÔÏ󼯺ϵÄÓû§Ãû³Æ¡£
£¨2£©½¨Á¢Ó ......