]]>A SQL Joke http://www.tkk7.com/donnielife/archive/2009/04/06/264128.htmldonniedonnieMon, 06 Apr 2009 09:03:00 GMThttp://www.tkk7.com/donnielife/archive/2009/04/06/264128.htmlhttp://www.tkk7.com/donnielife/comments/264128.htmlhttp://www.tkk7.com/donnielife/archive/2009/04/06/264128.html#Feedback0http://www.tkk7.com/donnielife/comments/commentRss/264128.htmlhttp://www.tkk7.com/donnielife/services/trackbacks/264128.htmlA SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'
]]>Ora-01846: not a valid day of the week http://www.tkk7.com/donnielife/archive/2009/04/06/264125.htmldonniedonnieMon, 06 Apr 2009 08:00:00 GMThttp://www.tkk7.com/donnielife/archive/2009/04/06/264125.htmlhttp://www.tkk7.com/donnielife/comments/264125.htmlhttp://www.tkk7.com/donnielife/archive/2009/04/06/264125.html#Feedback0http://www.tkk7.com/donnielife/comments/commentRss/264125.htmlhttp://www.tkk7.com/donnielife/services/trackbacks/264125.html
Ora-01846: not a valid day of the week
鍑虹幇鐨勬槸涓枃鐨勫瓧絎︽棩鏈燂紝濡備笅錛氭槦鏈熶簲 12鏈?19 13:53:15 2008
鏄瓧絎﹂泦鐨勯棶棰橈紝瑙e喅錛?br />
alter session set nls_date_language = 'American'
]]>plsql error handling http://www.tkk7.com/donnielife/archive/2009/03/25/261817.htmldonniedonnieWed, 25 Mar 2009 02:52:00 GMThttp://www.tkk7.com/donnielife/archive/2009/03/25/261817.htmlhttp://www.tkk7.com/donnielife/comments/261817.htmlhttp://www.tkk7.com/donnielife/archive/2009/03/25/261817.html#Feedback0http://www.tkk7.com/donnielife/comments/commentRss/261817.htmlhttp://www.tkk7.com/donnielife/services/trackbacks/261817.htmlSET SERVEROUTPUT ON; DECLARE stock_price NUMBER :=9.73; net_earnings NUMBER :=0; pe_ratio NUMBER; BEGIN -- Calculation might cause division-by-zero error. pe_ratio := stock_price / net_earnings; dbms_output.put_line('Price/earnings ratio = '|| pe_ratio); EXCEPTION -- exception handlers begin -- Only one of the WHEN blocks is executed. WHEN ZERO_DIVIDE THEN-- handles 'division by zero' error dbms_output.put_line('Company must have had zero earnings.'); pe_ratio :=null; WHEN OTHERS THEN-- handles all other errors dbms_output.put_line('Some other kind of error occurred.'); pe_ratio :=null; END; -- exception handlers and block end here /
ref : http://www.sc.ehu.es/siwebso/KZCC/Oracle_10g_Documentacion/appdev.101/b10807/07_errs.htm
]]>ORACLE 10.2.0.1涓嬪惎鐢╝utotrace銆?/title>http://www.tkk7.com/donnielife/archive/2009/03/16/260120.htmldonniedonnieMon, 16 Mar 2009 14:35:00 GMThttp://www.tkk7.com/donnielife/archive/2009/03/16/260120.htmlhttp://www.tkk7.com/donnielife/comments/260120.htmlhttp://www.tkk7.com/donnielife/archive/2009/03/16/260120.html#Feedback0http://www.tkk7.com/donnielife/comments/commentRss/260120.htmlhttp://www.tkk7.com/donnielife/services/trackbacks/260120.html
2, run @utlxplan;
3, create public synonym plan_table to public; --no need to run in oracle10,oracle default
4, grant all on plan_table to public;--no need to run in oracle10,oracle default, here public can be any user;
----create role plustrace and grant it to user
1, cd [oracle_home]\sqlplus\admin;
2, conn sqlplus as sysdba;
3, run @plustrce;
4, grant plustrace to public;
---test
1, conn sqlplus with user scott;
1.1, set autotrace on;
2, run : select * from dual;
3, show stat info;
--1.1 鍙夐」錛?set autotrace off: 涓嶇敓鎴愭姤鍛婏紝榛樿錛?br />
set autotrace on explain: 鎶ュ憡鍙樉紺轟紭鍖栧櫒鎵ц璺緞錛?br />
set autotrace on statistics: 鎶ュ憡鍙樉紺簊ql璇彞鎵ц緇熻淇℃伅錛?br />
set autotrace on: 鎶ュ憡鏄劇ず浼樺寲鍣ㄦ墽琛岃礬寰勶紝sql璇彞緇熻淇℃伅錛?br />
set autotrace traceonly: 鎶ュ憡鏄劇ず浼樺寲鍣ㄦ墽琛岃礬寰勶紝sql璇彞緇熻淇℃伅錛屼笉鏄劇ず鏌ヨ杈撳嚭錛?br />
]]>璁劇疆sqlplus榪愯鐜http://www.tkk7.com/donnielife/archive/2009/03/16/260105.htmldonniedonnieMon, 16 Mar 2009 14:07:00 GMThttp://www.tkk7.com/donnielife/archive/2009/03/16/260105.htmlhttp://www.tkk7.com/donnielife/comments/260105.htmlhttp://www.tkk7.com/donnielife/archive/2009/03/16/260105.html#Feedback0http://www.tkk7.com/donnielife/comments/commentRss/260105.htmlhttp://www.tkk7.com/donnielife/services/trackbacks/260105.html
sqlplus鍏佽寤虹珛涓涓猯ogin.sql錛岄氳繃璁劇疆鐜鍙橀噺SQLPATH錛屾寚鍚戞枃浠舵墍鍦ㄧ洰褰曪紝姣忔鍚姩sqlplus閮戒細鎵ц榪欎釜鑴氭湰銆?br />
login.sql渚嬪瓙錛?br />
define _editor=notepad set serveroutput on size 1000000 set trimspool on setlong5000 set linesize 100 set pagesize 9999 column plan_plus_exp format a80 column global_name new_value gname set termout off define gname=idle column global_name new_value gname selectlower(user) ||'@'|| substr( global_name, 1, decode( dot, 0, length(global_name), dot-1) ) global_name from (select global_name, instr(global_name,'.') dot from global_name ); set sqlprompt '&gname> ' set termout on
define _editor: sqlplus榛樿鐨勭紪杈戝櫒錛?br />
set serveroutput on size 1000000錛氶粯璁ゆ墦寮DBMS_OUTPUT,灝嗙紦鍐插尯璁劇疆灝藉彲鑳藉ぇ錛?br />
]]>How to grant select on system views like v$session to any user.http://www.tkk7.com/donnielife/archive/2009/03/16/260102.htmldonniedonnieMon, 16 Mar 2009 13:59:00 GMThttp://www.tkk7.com/donnielife/archive/2009/03/16/260102.htmlhttp://www.tkk7.com/donnielife/comments/260102.htmlhttp://www.tkk7.com/donnielife/archive/2009/03/16/260102.html#Feedback0http://www.tkk7.com/donnielife/comments/commentRss/260102.htmlhttp://www.tkk7.com/donnielife/services/trackbacks/260102.html
sys@ORCL> grant select on v$session to scott;
grant select on v$session to scott
*
絎?1 琛屽嚭鐜伴敊璇?
ORA-02030: 鍙兘浠庡浐瀹氱殑琛?瑙嗗浘鏌ヨ