Oracle Òì³£
OracleÒì³£·ÖΪ3ÖÖ:
(1)Ô¤¶¨ÒåÒì³£:no_data_foundµÈ,ÊÇOracleϵͳ¶¨ÒåµÄÒì³£.
declare
s_test varchar2
begin
select id into s_test from test; --´Ëʱtest±íÎÞÊý¾Ý
exception
when no_data_found then
raise_application_error(-20001, 'ûÓÐÊý¾Ý');
end;
(2)×Ô¶¨ÒåÒì³£:×Ô¼º¶¨ÒåµÄÒì³£,×Ô¼ºÅ×,×Ô¼º²¶»ñ.
declare
exp_test exception;
begin
if 1 = 1 then
raise exp_test;
end if;
exception
when exp_test then
raise_application_error(-20002, '×Ô¶¨ÒåÒì³£');
end;
(3)·ÇÔ¤¶¨ÒåÒì³£.
--Õâ¸öÀý×ӾͲ»ÐèÒª×Ô¼ºÅ×,ÒòΪÒѾ°ÑÖ÷¼ü³åÍ»µÄÒì³£¸ø¸²¸ÇÁË,ËùÒÔÖ»ÒªÊÇÖ÷¼ü³åÍ»,ÄÇô¾ÍÊÇexp_testÀ´´úÌæÒÔǰÄǸöÁË.
declare
exp_test exception;
progam exception_init(exp_test ,-1); --¸²¸Ç-1Õâ¸öÒì³£,-1´ú±íÖ÷¼ü³åÍ»
begin
insert into test values('1'); --test±íµÄÖ÷¼ü´æÔÚ1Õâ¸öÖµ.
exception
when exp_test then
raise_application_error(-20003, 'Ö÷¼ü³åÍ»');
end;
ÅжϲÎÊýµÄ.
create or replace procedure addContent_test
(
s_type in varchar2,
s_count in number,
s_language in varchar2
)
is
exp_type exception;
exp_count exception;
exp_language exception;
begin
if s_type <> 50
and s_type <> 51
and s_type <> 52
and s_type <> 53
and s_type <> 54
and s_type <> 55
and s_type <> 56
and s_type <> 57
and s_type <> 0
and s_type <> 2
and s_type <> 3
and s_type <> 99999999 then
raise exp_type;
end if;
if s_count < 1 or s_count > 100 then
raise exp_count;
end if;
dbms_output.put_line(to_number(instr(s_language, ',',1,2)));
if instr(s_language, ',',1,2) > 0 then
raise exp_language;
end if;
exception
Ïà¹ØÎĵµ£º
Èý¡¢Ê¹ÓÃSchedules
¡¡¡¡10g ÖÐÐÂÍÆ³öµÄSCHEDULER¿ÉÄÜȷʵ»áÈúܶà³õ½Ó´¥µÄÅóÓѸоõÔÎÍ·ÔÎÄÔ£¬Ïà±È֮ǰµÄjobs£¬SCHEDULERÖÐÐÂÔöµÄ¸ÅÄîÌ«¶à¡£±ÈÈç˵jobs£¬ÈÔÈ»¿ÉÒÔÀí½â³É֮ǰ°æ±¾ÖеÄjobs£¬²»¹ý¹¦Äܸü¼ÓÇ¿´ó(×¢Òâ10gÖÐÒ²ÈÔÈ»¿ÉÒÔʹÓÃÆÕͨjobs£¬ÕâÊÇ·Ï»°£¬ÏàÐÅ¿´±¾ÆªÎÄÕµÄÅóÓÑĿǰӦ¸Ã»¹ÊÇÕâÑùÔÚÓÃ)£¬±ÈÈç˵program£¬Ö¸µÄÊÇÔ ......
oracleѧϰÀú³ÌÖ®´æ´¢¹ý³Ì
(1) ´æ´¢¹ý³Ìͨ¹ý²ÎÊý´«µÝ,°²È«ÐÔ¸ß,¿É·ÀÖ¹×¢Èëʽ¹¥»÷.
(2) ²éѯµÄÓï¾äÔÚ´æ´¢¹ý³ÌÀï,Óë³ÌÐò²»Ïà¹Ø,Èç¹ûÒÔºóÒªÐ޸ijÌÐò»òÕßÊý¾Ý¿â,¶¼²»»á³öÏÖÁ¬Ëø·´Ó¦,Ôö¼Óϵͳ¿ÉÀ©Õ¹ÐÔ.
(3) ÍøÕ¾Ö´ÐвéѯµÄʱºò,Ö»ÐèÒª´«µÝ¼òµ¥µÄ²ÎÊý¾Í¿ÉÒÔÁË,ÎÞÂÛÊÇ´úÂëÓÅ»¯ÉÏ»¹ÊDzéѯÓÅ»¯É϶¼¿ÉÒÔ×öµ½¸ßЧ.
(4) ÔÊÐíÄ£¿é ......
Ò». ÀûÓÃrowidÀ´µÃµ½Ïà¹ØÐÅÏ¢
SQL> conn sys/admin as sysdba
ÒÑÁ¬½Ó¡£
SQL> create table bl(id number);
±íÒÑ´´½¨¡£
SQL> insert into bl values(1);
ÒÑ´´½¨ 1 ÐС£
SQL> select owner,segment_name,file_id,RELATIVE_FNO,block_id from dba_extents wh
ere owner='SYS' and segment_name='B ......
ÔÚÒ»¸ö¸ß¿ÉÓÃϵͳÖУ¬Èç¹ûÐèÒª¸Ä±äÒ»¸ö±íµÄ¶¨ÒåÊÇÒ»¼þ±È½Ï¼¬ÊÖµÄÎÊÌ⣬ÓÈÆäÊǶÔ
ÓÚ7×24ϵͳ¡£OracleÌṩµÄ»ù±¾Óï·¨»ù±¾¿ÉÒÔÂú×ãÒ»°ãÐÔÐ޸쬵«ÊǶÔÓÚ°ÑÆÕͨ¶Ñ±í¸ÄΪ·ÖÇø±í£¬°ÑË÷Òý×éÖ¯±íÐÞ¸ÄΪ¶Ñ±íµÈ²Ù×÷¾ÍÎÞ·¨Íê³ÉÁË¡£¶øÇÒ£¬
¶ÔÓÚ±»´óÁ¿DMLÓï¾ä·ÃÎÊµÄ±í£¬ÐÒÔ˵ÄÊÇ£¬Oracle´Ó9i°æ±¾¿ªÊ¼ÌṩÁËÔÚÏßÖØ¶¨Òå±í¹¦ÄÜ£¬Í ......