±±´óÇàÄñoracleѧϰ±Ê¼Ç18
Òì³£
Ô¤¶¨ÒåÒì³£
oracleΪ³£¼û´íÎóÔ¤¶¨Òå
ÔÚDBMS_STANDARD³ÌÐò°üÖÐÌṩÁËÕâЩ¶¨Òå
²»ÐèÒªÏÔʾÉùÃ÷
declare
sex student.stu_sex%type;
begin
select stu_sex into sex from student;
dbms_output.put_line('sex:'||sex);
exception
when no_data_found then
dbms_output.put_line('no such student!');
when too_many_rows then
dbms_output.put_line('too many rows selected!');
when others then
dbms_output.put_line('other error!');
end;
Ô¤¶¨ÒåÒì³£Ãû
²úÉúÔÒò
ACCESS_INTO_NULL
䶨Òå¶ÔÏó
CASE_NOT_FOUND
CASEÖÐÈôΪ°üº¬ÏàÓ¦µÄWHEN£¬²¢ÇÒûÓÐÉèÖÃELSEʱ
COLLECTION_IS_NULL
¼¯ºÏÔªËØδ³õʼ»¯
CURSER_ALREADY_OPEN
ÓαêÒѾ´ò¿ª
DUP_VAL_ON_INDEX
ΨһË÷Òý¶ÔÓ¦µÄÁÐÉÏÓÐÖظ´Öµ
INVALID_CURSOR
ÔÚ²»ºÏ·¨µÄÓαêÉϽøÐвÙ×÷
INVALID_NUMBER
ÄÚǶµÄSQLÓï¾ä²»Äܽ«×Ö·ûת»»ÎªÊý×Ö
NO_DATA_FOUND
ʹÓÃselect into δ·µ»ØÐУ¬»òÓ¦ÓÃË÷Òý±íδ³õʼ»¯ÔªËØʱ
TOO_MANY_ROWS
Ö´ÐÐselect intoʱ»ú¹ý¼¯³¬¹ýÒ»ÐÐ
ZERO_DIVIDE
³ýÊýΪ0
SUBSCRIPT_BEYOND_COUNT
ÔªËØϱ곬¹ýǶÌ×±í»òVARRAYµÄ×î´óÖµ
SUBSCRIPT_OUTSIDE_LIMIT
ʹÓÃǶÌ×±í»òVARRAYʱ½«Ï±êÖƶ¨Îª¸ºÊý
VALUE_ERROR
¸³ÖµÊ±£¬±äÁ¿³¤¶È²»×ãÒÔÈÝÄÉʵ¼ÊÊý¾Ý
LOGIN_DENIED
PL/SQL Ó¦ÓóÌÐòÁ¬½Óµ½ oracle Êý¾Ý¿âʱ£¬ÌṩÁ˲»ÕýÈ·µÄÓû§Ãû»òÃÜÂë
NOT_LOGGED_ON
PL/SQL Ó¦ÓóÌÐòÔÚûÓÐÁ¬½Ó oralce Êý¾Ý¿âµÄÇé¿öÏ·ÃÎÊÊý¾Ý
PROGRAM_ERROR
PL/SQL ÄÚ²¿ÎÊÌ⣬¿ÉÄÜÐèÒªÖØ×°Êý¾Ý×ֵ䣦 pl./SQL ϵͳ°ü
ROWTYPE_MISMATCH
ËÞÖ÷Óαê±äÁ¿Óë PL/SQL Óαê±äÁ¿µÄ·µ»ØÀàÐͲ»¼æÈÝ
SELF_IS_NULL
ʹÓöÔÏóÀàÐÍʱ£¬ÔÚ null ¶ÔÏóÉϵ÷ÓöÔÏó·½·¨
STORAGE_ERROR
ÔËÐÐ PL/SQL ʱ£¬³¬³öÄÚ´æ¿Õ¼ä
SYS_INVALID_ID
ÎÞЧµÄ ROWID ×Ö·û´®
TIMEOUT_ON_RESOURCE
Oracle Ôڵȴý×ÊԴʱ³¬Ê±
Óû§×Ô¶¨ÒåÒì³£
ÉùÃ÷ÀàÐÍΪExceptionÀàÐÍ
Ö»ÄÜÖ÷¶¯ÓÉraiseÅ׳ö
declare
Dup_Value Exception;
icount int := 0;
begin
select count(*) into icount from student;
if icount > 0 then
Ïà¹ØÎĵµ£º
ʹØCUBE ROLLUP GROUPING SETS£¨1£©
ÔÎÄÒý×Ô£º ¾ÛºÏÊÇÊý¾Ý²Ö¿âµÄ»ù´¡¡£ÎªÁËÌá¸ß¾ÛºÏµÄÐÔÄÜ¡£OracleÌṩÁËGroup By Ìõ¿îµÄÀ©Õ¹¡£
1£® CUBE, ROLLUPÀ©Õ¹
2£® 3¸ögroupingº¯Êý
3£® Grouping setÀ©Õ¹
CUBE ROLLUP ......
ÔÚOracleÖеÄÊ÷ÐβÙ×÷
1.È¡×ӽڵ㼰·¾¶(ÕýÊ÷):
select t.id ,t.code, t.name ,t.pid
,SYS_CONNECT_BY_PATH(t.id,'.')||'.' as IdPath
from tas_catalog t
--where id!=110
start with id=110
connect by pid = prior id
order siblings by id
2.È¡¸÷¼¶¸¸½Úµã(µ¹Ê÷)£º
select t.id ,t.code, t.na ......
IP µØÖ·×öÈçÏÂÐ޸ģº
Public IP 10.85.10.119/121 -- > 10.85.10.219/221
Privite IP 192.168.1.119/121 -- > 192.168.1.219/221
Virtual IP 10.85.10.122/123 -- ......
in/not inÔÚÅжÏNULLʱÓõÄÓë=/<>Ò»ÑùµÄ·½Ê½£¬¼´±ØÐëÓÃis nullÀ´Åжϣ¬·ñÔòʼÖÕΪʧ°Ü¡£
Óï¾ä
select 'true' from dual where (1,2) not in ((2,3),(2,null));
³É¹¦µÄÔÒòÔÚÓÚÅж϶þÔªÖµÊ±Ê ......
oracleÖÐ×Ô¶¨ÒåÊý¾ÝÀàÐÍ
oracleÖÐÓлù±¾µÄÊý¾ÝÀàÐÍ£¬Èçnumber£¬varchar2£¬date£¬numeric£¬float....µ«ÓÐʱºòÎÒÃÇÐèÒªÌØÊâµÄ¸ñʽ£¬È罫name¶¨ÒåΪ
£¨firstname,lastname£©µÄÐÎʽ£¬ÎÒÃÇÏë°ÑÕâ¸ö×÷Ϊһ¸ö±íµÄÒ»Áп´´ý£¬Õâʱºò¾Í²»ÒªÎÒÃÇ×Ô¼º¶¨ÒåÒ»¸öÊý¾ÝÀàÐÍ
create or replace type type_name as object(firstname varchar ......