ORACLE³£ÓÃFAQ
µÚÒ»²¿·Ö¡¢SQL&PL/SQL
[Q]ÔõôÑù²éѯÌØÊâ×Ö·û£¬ÈçͨÅä·û%Óë_
[A]select * from table where name like 'A_%' escape ''
[Q]ÈçºÎ²åÈëµ¥ÒýºÅµ½Êý¾Ý¿â±íÖÐ
[A]¿ÉÒÔÓÃASCIIÂë´¦Àí£¬ÆäËüÌØÊâ×Ö·ûÈç&Ò²Ò»Ñù£¬Èç
insert into t values('i'||chr(39)||'m'); -- chr(39)´ú±í×Ö·û'
»òÕßÓÃÁ½¸öµ¥ÒýºÅ±íʾһ¸ö
or insert into t values('I''m'); --Á½¸ö''¿ÉÒÔ±íʾһ¸ö'
[Q]ÔõÑùÉèÖÃÊÂÎñÒ»ÖÂÐÔ
[A]set transaction [isolation level] read committed;ĬÈÏÓï¾ä¼¶Ò»ÖÂÐÔ
set transaction [isolation level] serializable;
read only;ÊÂÎñ¼¶Ò»ÖÂÐÔ
[Q]ÔõôÑùÀûÓÃÓαê¸üÐÂÊý¾Ý
[A]cursor c1 is
select * from tablename
where name is null for update [of column]
……
update tablename set column = ……
where current of c1;
[Q]ÔõÑù×Ô¶¨ÒåÒì³£
[A] pragma_exception_init(exception_name,error_number);
Èç¹ûÁ¢¼´Å׳öÒì³£
raise_application_error(error_number,error_msg,true|false);
ÆäÖÐnumber´Ó-20000µ½-20999£¬´íÎóÐÅÏ¢×î´ó2048B
Òì³£±äÁ¿
SQLCODE´íÎó´úÂë
SQLERRM´íÎóÐÅÏ¢
[Q]Ê®½øÖÆÓëÊ®Áù½øÖƵÄת»»
[A]8iÒÔÉÏ°æ±¾£º
to_char(100,'XX')
to_number('4D','XX')
8iÒÔϵĽøÖÆÖ®¼äµÄת»»²Î¿¼ÈçϽű¾
create or replace function to_base( p_dec in number, p_base in number )
return varchar2
is
l_str varchar2(255) default NULL;
l_num number default p_dec;
l_hex varchar2(16) default '0123456789ABCDEF';
begin
if ( p_dec is null or p_base is null ) then
return null;
end if;
if ( trunc(p_dec) <> p_dec OR p_dec < 0 ) then
raise PROGRAM_ERROR;
end if;
loop
l_str := substr( l_hex, mod(l_num,p_base)+1, 1 ) || l_str;
l_num := trunc( l_num/p_base );
exit when ( l_num = 0 );
end loop;
return l_str;
end to_base;
/
create or replace function to_dec
( p_str in varchar2,
p_from_base in number default 16 ) return number
is
l_num number default 0;
l_hex varchar2(16) default '0123456789ABCDEF';
begin
if ( p_str is null or p_from_base is null ) then
return null;
end if;
for i in 1 .. length(p_str) loop
l_num := l_num * p_from_base + instr(l_hex,upper(substr(p_str,i,1)))-1;
end lo
Ïà¹ØÎĵµ£º
ÈçºÎ¶¨ÒåÓαêÀàÐÍ
TYPE ref_type_name IS REF CURSOR [RETURN return_type];
ÉùÃ÷Óαê±äÁ¿
cursor_name ref_type_name;
´Ó¼¼Êõµ×²ã¿´£¬Á½ÕßÊÇÏàͬµÄ¡£ÆÕͨplsql cursorÔÚ¶¨ÒåʱÊÇ“¾²Ì¬”µÄ¡£¶øRef cursors¿ÉÒÔ¶¯Ì¬´ò¿ª¡£
ÀýÈçÏÂÃæÀý×Ó£º
Declare
type rc is ref cursor;
cursor c is select * from dual ......
Oracle Process Structure
Oracle takes advantage of various types of processes:
¡¡—User process: Started at the time a database user requests connection to the Oracle server
—Server process: Connects to the Oracle instance and is started when a user establishes a session
& ......
2009-11-15 13:06:35
½ñÌìÔÚITPUB·¢ÏÖһƪÎÄÕ£¬ÀÏÔçÒÔÇ°µÄÁË£¬Ð´µÄÂùÓÐÒâ˼£¬ÌØÒâת¹ýÀ´Êղء£
¶ÔÓÚ Oracle µÄ rownum ÎÊÌ⣬ºÜ¶à×ÊÁ϶¼Ëµ²»Ö§³Ö>,>=,=,between...and£¬Ö»ÄÜÓÃÒÔÉÏ·ûºÅ(<¡¢<=¡¢!=)£¬²¢·Ç˵ÓÃ>, >=,=,between..and ʱ»áÌáʾSQLÓï·¨´íÎ󣬶øÊǾ³£ÊDz鲻³öÒ»Ìõ¼Ç¼À´£¬»¹»á³öÏÖËƺ ......
ÔÚÊý¾Ý¿âδÆô¶¯Ö®Ç°µÇ½´Ó¶øÆô¶¯Êý¾Ý¿âÈç¹ûûÓпÚÁîÎļþ£¬ÔÚÊý¾Ý¿âδÆô¶¯Ö®Ç°¾ÍÖ»ÄÜͨ¹ý²Ù×÷ϵͳÈÏÖ¤.ʹÓÃRman£¬ºÜ¶àʱºòÐèÒªÔÚnomount,mountµÈ״̬¶ÔÊý¾Ý¿â½øÐд¦Àí¡£ËùÒÔͨ³£ÒªÇósysdbaȨÏÞÈç¹ûÊôÓÚ±¾µØDBA×飬¿ÉÒÔͨ¹ý²Ù×÷ϵͳÈÏÖ¤µÇ½Èç¹ûÊÇÔ¶³ÌsysdbaµÇ½£¬ÐèҪͨ¹ýpasswordfileÈÏÖ¤¡£
1.remote_login_passwordfile ......
Êý¾Ý×ÖµäÊÇOracle´æ·ÅÓйØÊý¾Ý¿âÐÅÏ¢µÄµØ·½£¬ÆäÓÃ;ÊÇÓÃÀ´ÃèÊöÊý¾ÝµÄ¡£±ÈÈçÒ»¸ö±íµÄ´´½¨ÕßÐÅÏ¢£¬´´½¨Ê±¼äÐÅÏ¢£¬ËùÊô±í¿Õ¼äÐÅÏ¢£¬Óû§·ÃÎÊȨÏÞÐÅÏ¢µÈ¡£µ±Óû§ÔÚ¶ÔÊý¾Ý¿âÖеÄÊý¾Ý½øÐвÙ×÷ʱÓöµ½À§ÄѾͿÉÒÔ·ÃÎÊÊý¾Ý×ÖµäÀ´²é¿´ÏêϸµÄÐÅÏ¢¡£
OracleÖеÄÊý¾Ý×ÖµäÓо²Ì¬ºÍ¶¯Ì¬Ö®·Ö¡£¾²Ì¬Êý¾Ý×ÖµäÖ÷ÒªÊÇÔÚÓû§·ÃÎÊÊý¾Ý×Öµäʱ²»»á·¢ ......