<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Oracle DBA Daily Experiences</title>
	<atom:link href="http://blog.flimatech.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flimatech.com</link>
	<description>Share and promote Oracle info, technology, tips and solutions</description>
	<lastBuildDate>Fri, 03 Feb 2012 05:03:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Example of bulk collect and performance using different values of limit</title>
		<link>http://blog.flimatech.com/2012/01/19/example-of-bulk-collect-and-performance-using-different-values-of-limit/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=example-of-bulk-collect-and-performance-using-different-values-of-limit</link>
		<comments>http://blog.flimatech.com/2012/01/19/example-of-bulk-collect-and-performance-using-different-values-of-limit/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 06:38:02 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[bulk]]></category>
		<category><![CDATA[collect]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1922</guid>
		<description><![CDATA[Sample code that shows using BULK COLLECT and performance of using different values for LIMIT. declare cursor l_cur is select * from scott.emp; type emp_tbl is table of l_cur%rowtype index by pls_integer; l_emp emp_tbl; limit_in number; i number; begin limit_in := &#38;limit_param; open l_cur; loop fetch l_cur bulk collect into l_emp limit limit_in; for i [...]]]></description>
			<content:encoded><![CDATA[<p>Sample code that shows using BULK COLLECT and performance of using different values for LIMIT.</p>
<p>declare<br />
   cursor l_cur is select * from scott.emp;<br />
   type emp_tbl is table of l_cur%rowtype index by pls_integer;<br />
   l_emp emp_tbl;<br />
   limit_in number;<br />
   i number;<br />
begin<br />
   limit_in := &amp;limit_param;<br />
   open l_cur;<br />
   loop<br />
      fetch l_cur bulk collect into l_emp limit limit_in;<br />
      for i in 1..l_emp.count<br />
      loop<br />
         null;<br />
      end loop;<br />
      exit when l_emp.count &lt; limit_in;<br />
   end loop;<br />
   close l_cur;<br />
end;</p>
<p><b>Limit value 1:</b> 25.76 seconds<br />
<b>Limit value 10:</b> 03.54 seconds<br />
<b>Limit value 100:</b> 01.28 seconds<br />
<b>Limit value 1000:</b> 00.95 seconds<br />
<b>Limit value 2000:</b> 01.00 seconds<br />
<b>Limit value 3000:</b> 01.03 seconds<br />
<b>Limit value 5000:</b> 01.06 seconds<br />
<b>Limit value 10000:</b> 01.20 seconds</p>
<p>As you notice in the case above as one increases the value of LIMIT after 1000, the execution time increases slightly.  The following was timed using &#8220;set timing on&#8221; on SQL*Plus.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2012/01/19/example-of-bulk-collect-and-performance-using-different-values-of-limit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to set vim/gvim on windows?</title>
		<link>http://blog.flimatech.com/2012/01/19/how-to-set-vimgvim-on-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-set-vimgvim-on-windows</link>
		<comments>http://blog.flimatech.com/2012/01/19/how-to-set-vimgvim-on-windows/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 05:29:50 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[vi]]></category>
		<category><![CDATA[gvim]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1920</guid>
		<description><![CDATA[Using the following steps one can setup vim/gvim to run on windows. 1) Add the following new variable VIM on your system. Example: VIM=C:\apps\vim\vim73 (Where C:\apps\vim\vim73 is where vim/gvim is installed) 2) Copy the file %VIM%\vimrc_example.vim as _vimrc in %VIM% folder 3) Add the following 2 lines at the end in %VIM%\_vimrc so it sets [...]]]></description>
			<content:encoded><![CDATA[<p>Using the following steps one can setup vim/gvim to run on windows.</p>
<p>1) Add the following new variable VIM on your system.   Example: VIM=C:\apps\vim\vim73  (Where C:\apps\vim\vim73 is where vim/gvim is installed)<br />
2) Copy the file %VIM%\vimrc_example.vim as _vimrc in %VIM% folder<br />
3) Add the following 2 lines at the end in %VIM%\_vimrc so it sets up vim for windows<br />
source $VIM/mswin.vim<br />
behave mswin</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2012/01/19/how-to-set-vimgvim-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example of using tracefile_identifier</title>
		<link>http://blog.flimatech.com/2012/01/07/example-of-using-tracefile_identifier/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=example-of-using-tracefile_identifier</link>
		<comments>http://blog.flimatech.com/2012/01/07/example-of-using-tracefile_identifier/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 01:41:48 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[trace]]></category>
		<category><![CDATA[10046]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[file name]]></category>
		<category><![CDATA[filename]]></category>
		<category><![CDATA[logon]]></category>
		<category><![CDATA[tracefile_identifier]]></category>
		<category><![CDATA[trigger]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1917</guid>
		<description><![CDATA[Using &#8220;tracefile_identifier&#8221; Oracle will add that to the name of the user&#8217;s trace filename so the file can easily be identified. For example if one needs to trace multiple users session who have different schema or OS user then using &#8220;tracefile_identifier&#8221; one can identify the trace file specific to a user. Example: The following trigger [...]]]></description>
			<content:encoded><![CDATA[<p>Using &#8220;tracefile_identifier&#8221; Oracle will add that to the name of the user&#8217;s trace filename so the file can easily be identified.  For example if one needs to trace multiple users session who have different schema or OS user then using &#8220;tracefile_identifier&#8221; one can identify the trace file specific to a user.</p>
<p>Example:  The following trigger will create a trace file with the user&#8217;s OSuser and machine part of the filename for any user who login with &#8220;SCOTT&#8221;</p>
<p>CREATE OR REPLACE TRIGGER sys.session_trace_on<br />
&#8211; to be created by sys user<br />
AFTER LOGON ON database<br />
DECLARE<br />
   v_machinename VARCHAR2(64);<br />
   v_ora_username VARCHAR2(30) DEFAULT NULL;<br />
   v_os_username VARCHAR2(30);<br />
   v_sid NUMBER;<br />
   v_serial NUMBER;<br />
   v_program VARCHAR2(48);<br />
   v_numuser NUMBER;<br />
   CURSOR c1 IS<br />
      SELECT sid, serial#, osuser, machine, program<br />
      FROM v$session<br />
      WHERE sid = userenv(&#039;sid&#039;)<br />
      and username = &#039;SCOTT&#039;;<br />
BEGIN<br />
   OPEN c1;<br />
   FETCH c1 INTO v_sid, v_serial, v_os_username, v_machinename, v_program;<br />
   IF c1%FOUND THEN<br />
      &#8212; DBMS_SESSION.set_sql_trace (TRUE);<br />
      v_machinename := replace(replace(v_machinename, &#039;\&#039;, &#039;_&#039;), &#039;/&#039;, &#039;_&#039;);<br />
      v_os_username := replace(replace(v_os_username, &#039;\&#039;, &#039;_&#039;), &#039;/&#039;, &#039;_&#039;);<br />
      EXECUTE IMMEDIATE &#039;alter session set tracefile_identifier=&#039;&#039;&#039; || trim(v_os_username) || &#039;&#039;&#039;&#039;;<br />
      EXECUTE IMMEDIATE &#039;alter session set events &#039;&#039;10046 trace name context forever, level 12&#039;&#039;&#039;;<br />
   END IF;<br />
   CLOSE c1;<br />
END;<br />
/</p>
<p>Trace file created:<br />
ls testdb_ora_5480_CAL-AMIN_Administrator.trc</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2012/01/07/example-of-using-tracefile_identifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add a comment when changing a parameter?</title>
		<link>http://blog.flimatech.com/2012/01/07/how-to-add-a-comment-when-changing-a-parameter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-add-a-comment-when-changing-a-parameter</link>
		<comments>http://blog.flimatech.com/2012/01/07/how-to-add-a-comment-when-changing-a-parameter/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 22:07:14 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[Initialization]]></category>
		<category><![CDATA[Parameters]]></category>
		<category><![CDATA[spfile]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[comment]]></category>
		<category><![CDATA[parameter]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1913</guid>
		<description><![CDATA[In &#8220;ALTER SYSTEM&#8221; one can include a comment which gets recorded in the spfile and also in v$parameter as shown below. It can be used to record why parameter was changed. Example: SQL&#62; alter system set open_cursors=1000 comment=&#039;07-Jan-2012 Changed AJ needed for application XYZ&#039;; SQL&#62; select value, update_comment from v$parameter where name = &#039;open_cursors&#039;; VALUE [...]]]></description>
			<content:encoded><![CDATA[<p>In &#8220;ALTER SYSTEM&#8221; one can include a comment which gets recorded in the spfile and also in v$parameter as shown below. It can be used to record why parameter was changed.</p>
<p>Example:<br />
SQL&gt; alter system set open_cursors=1000 comment=&#039;07-Jan-2012 Changed AJ needed for application XYZ&#039;;</p>
<p>SQL&gt; select value, update_comment from v$parameter where name = &#039;open_cursors&#039;;</p>
<p>VALUE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
UPDATE_COMMENT<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
400</p>
<p>$ strings spfileTESTDB.ORA | grep open_cursors<br />
*.open_cursors=400#07-Jan-2012 Changed AJ needed for application XYZ</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2012/01/07/how-to-add-a-comment-when-changing-a-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add a new not null column in a table without providing a default value?</title>
		<link>http://blog.flimatech.com/2012/01/02/how-to-add-a-new-not-null-column-in-a-table-without-providing-a-default-value/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-add-a-new-not-null-column-in-a-table-without-providing-a-default-value</link>
		<comments>http://blog.flimatech.com/2012/01/02/how-to-add-a-new-not-null-column-in-a-table-without-providing-a-default-value/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 22:18:24 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[General DBA]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[column]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[new column]]></category>
		<category><![CDATA[not null]]></category>
		<category><![CDATA[novalidate]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1910</guid>
		<description><![CDATA[The following shows how to add in a table a new column that is NOT NULL when a table already has rows without providing a default value. SQL&#62; create table scott.testn ( x number not null); Table created. SQL&#62; insert into scott.testn values ( 11 ); 1 row created. SQL&#62; commit; Commit complete. &#045;&#045; First [...]]]></description>
			<content:encoded><![CDATA[<p>The following shows how to add in a table a new column that is NOT NULL when a table already has rows without providing a default value.</p>
<p>SQL&gt; create table scott.testn ( x number not null);</p>
<p>Table created.</p>
<p>SQL&gt; insert into scott.testn values ( 11 );</p>
<p>1 row created.</p>
<p>SQL&gt; commit;</p>
<p>Commit complete.</p>
<p>&#045;&#045; First step add new column without the NULL constraint<br />
SQL&gt; alter table scott.testn add nn number;</p>
<p>Table altered.</p>
<p>&#045;&#045; Then modify the column to be NOT NULL using NOVALIDATE<br />
SQL&gt; alter table scott.testn modify nn not null novalidate;</p>
<p>Table altered.</p>
<p>&#045;&#045; Shows the table doesn&#39;t show the NOT NULL constraint on the column NN yet<br />
SQL> desc scott.testn;<br />
 Name                                      Null?    Type<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
 X                                         NOT NULL NUMBER<br />
 NN                                                 NUMBER</p>
<p>&#045;&#045; As shown above even though not shown the NOT NULL constraint is there as new values cannot be inserted in the table that are NULL<br />
SQL> insert into scott.testn values (12, null);<br />
insert into scott.testn values (12, null)<br />
                                    *<br />
ERROR at line 1:<br />
ORA-01400: cannot insert NULL into (&#8220;SCOTT&#8221;.&#8221;TESTN&#8221;.&#8221;NN&#8221;)</p>
<p>&#045;&#045; Now we can enable the constraint by updating the rows that have NULL value so we need to find the constraint name<br />
SQL> select column_name, constraint_name from dba_cons_columns where table_name = &#39;TESTN&#39; and owner = &#39;SCOTT&#39;;</p>
<p>COLUMN_NAME          CONSTRAINT_NAME<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
X                    SYS_C005261<br />
NN                   SYS_C005262</p>
<p>&#045;&#045; Rows update<br />
SQL> update scott.testn set nn = 1 where nn is null;</p>
<p>1 row updated.</p>
<p>SQL> commit;</p>
<p>Commit complete.</p>
<p>&#045;&#045;<br />
SQL> alter table scott.testn modify constraint SYS_C005262 validate;</p>
<p>Table altered.</p>
<p>&#045;&#045; Shows the NOT NULL constraint on the column NN<br />
SQL> desc scott.testn;<br />
 Name                                      Null?    Type<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 X                                         NOT NULL NUMBER<br />
 NN                                        NOT NULL NUMBER</p>
<p>&#045;&#045; shows that one can&#39;t add a new column not null as table is not empty<br />
SQL&gt; alter table scott.testn add mm number not null;<br />
alter table scott.testn add mm number not null<br />
                  *<br />
ERROR at line 1:<br />
ORA-01758: table must be empty to add mandatory (NOT NULL) column</p>
<p>&#045;&#045; shows it can&#39;t add a new column not null with novalidate as table is not empty<br />
SQL&gt; alter table scott.testn add mm number not null novalidate;<br />
alter table scott.testn add mm number not null novalidate<br />
                  *<br />
ERROR at line 1:<br />
ORA-01758: table must be empty to add mandatory (NOT NULL) column</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2012/01/02/how-to-add-a-new-not-null-column-in-a-table-without-providing-a-default-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use PRAGMA EXCEPTION_INIT?</title>
		<link>http://blog.flimatech.com/2011/12/29/how-to-use-pragma-exception_init/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-use-pragma-exception_init</link>
		<comments>http://blog.flimatech.com/2011/12/29/how-to-use-pragma-exception_init/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 18:05:25 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[EXCEPTION_INIT]]></category>
		<category><![CDATA[PRAGMA]]></category>
		<category><![CDATA[raise]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1906</guid>
		<description><![CDATA[PRAGMA EXCEPTION_INIT &#8211; allows one to map ORA- error and it can be raised in PL/SQL code. The SQL Error number passed in &#8220;EXCEPTION_INIT&#8221; is the same as error code except for &#8220;NO_DATA_FOUND&#8221; ORA-01403 which is 100. See http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/errors.htm#BABGIIBI &#8211; Summary of Predefined PL/SQL Exceptions Example: declare no_rows_found exception; pragma exception_init(no_rows_found, 100); begin raise no_rows_found; [...]]]></description>
			<content:encoded><![CDATA[<p>PRAGMA EXCEPTION_INIT &#8211; allows one to map ORA- error and it can be raised in PL/SQL code.  The SQL Error number passed in &#8220;EXCEPTION_INIT&#8221; is the same as error code except for &#8220;NO_DATA_FOUND&#8221; ORA-01403 which is 100.<br />
See <a href='http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/errors.htm#BABGIIBI'>http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/errors.htm#BABGIIBI &#8211; Summary of Predefined PL/SQL Exceptions</a></p>
<p>Example:<br />
declare<br />
   no_rows_found exception;<br />
   pragma exception_init(no_rows_found, 100);<br />
begin<br />
   raise no_rows_found;<br />
end;<br />
/<br />
*<br />
ERROR at line 1:<br />
ORA-01403: no data found<br />
ORA-06512: at line 4</p>
<p>declare<br />
   too_many_rows exception;<br />
   pragma exception_init(too_many_rows, -1422);<br />
begin<br />
   raise too_many_rows;<br />
end;<br />
/<br />
*<br />
ERROR at line 1:<br />
ORA-01422: exact fetch returns more than requested number of rows<br />
ORA-06512: at line 5</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2011/12/29/how-to-use-pragma-exception_init/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix &#8220;Error accessing PRODUCT_USER_PROFILE&#8221;?</title>
		<link>http://blog.flimatech.com/2011/12/29/how-to-fix-error-accessing-product_user_profile/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-fix-error-accessing-product_user_profile</link>
		<comments>http://blog.flimatech.com/2011/12/29/how-to-fix-error-accessing-product_user_profile/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 18:02:29 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[SQL*Plus]]></category>
		<category><![CDATA[Error accessing PRODUCT_USER_PROFILE]]></category>
		<category><![CDATA[Product user profile]]></category>
		<category><![CDATA[PRODUCT_USER_PROFILE]]></category>
		<category><![CDATA[pupbld.sql]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1904</guid>
		<description><![CDATA[When logging in SQL*PLus if one receives the following message. SQL&#62; connect scott/tiger Error accessing PRODUCT_USER_PROFILE Warning: Product user profile information not loaded! You may need to run PUPBLD.SQL as SYSTEM This can be fixed by executing as SYSTEM SQL&#62; @?/sqlplus/admin/PUPBLD.SQL .. And after the script is run reconnect as the user. SQL&#62; connect scott/tiger [...]]]></description>
			<content:encoded><![CDATA[<p>When logging in SQL*PLus if one receives the following message.</p>
<p>SQL&gt; connect scott/tiger<br />
<b>Error accessing PRODUCT_USER_PROFILE<br />
Warning:  Product user profile information not loaded!<br />
You may need to run PUPBLD.SQL as SYSTEM</b></p>
<p>This can be fixed by executing as SYSTEM<br />
SQL&gt; @?/sqlplus/admin/PUPBLD.SQL<br />
..</p>
<p>And after the script is run reconnect as the user.<br />
SQL&gt; connect scott/tiger<br />
Connected.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2011/12/29/how-to-fix-error-accessing-product_user_profile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to schedule a snap for STATSPACK?</title>
		<link>http://blog.flimatech.com/2011/12/29/how-to-schedule-a-snap-for-statspack/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-schedule-a-snap-for-statspack</link>
		<comments>http://blog.flimatech.com/2011/12/29/how-to-schedule-a-snap-for-statspack/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 18:00:42 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[General DBA]]></category>
		<category><![CDATA[Statspack]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[dbms_job]]></category>
		<category><![CDATA[schedule]]></category>
		<category><![CDATA[statspack]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1902</guid>
		<description><![CDATA[One can automate taking of snapshots of STATSPACK by executing DBMS_JOB or by scheduling it through crontab. Schedule automatic STATSPACK through DBMS_JOB &#8211; By executing @?/rdbms/admin/spauto.sql it will schedule to run statspack once every hour which is the default. Output: SQL&#62; connect perstat@TESTDB Password: ********** SQL&#62; @?/rdbms/admin/spauto.sql PL/SQL procedure successfully completed. Job number for automated [...]]]></description>
			<content:encoded><![CDATA[<p>One can automate taking of snapshots of STATSPACK by executing DBMS_JOB or by scheduling it through crontab.</p>
<p><b>Schedule automatic STATSPACK through DBMS_JOB</b>  &#8211; By executing @?/rdbms/admin/spauto.sql it will schedule to run statspack once every hour which is the default.</p>
<p>Output:<br />
SQL&gt; connect perstat@TESTDB<br />
Password: **********<br />
SQL&gt; @?/rdbms/admin/spauto.sql</p>
<p>PL/SQL procedure successfully completed.</p>
<p>Job number for automated statistics collection for this instance<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Note that this job number is needed when modifying or removing<br />
the job:</p>
<p>     JOBNO<br />
&#8212;&#8212;&#8212;-<br />
         2</p>
<p>Job queue process<br />
~~~~~~~~~~~~~~~~~<br />
Below is the current setting of the job_queue_processes init.ora<br />
parameter &#8211; the value for this parameter must be greater<br />
than 0 to use automatic statistics gathering:</p>
<p>NAME                                 TYPE        VALUE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
job_queue_processes                  integer     1000</p>
<p>Next scheduled run<br />
~~~~~~~~~~~~~~~~~~<br />
The next scheduled run for this job is:</p>
<p>       JOB NEXT_DATE NEXT_SEC<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212; &#8212;&#8212;&#8211;<br />
         2 27-DEC-11 19:00:00</p>
<p><b>One can view the job by executing the following SQL.</b></p>
<p>SQL&gt; select * FROM User_jobs WHERE job = 2;</p>
<p>       JOB LOG_USER                       PRIV_USER<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
SCHEMA_USER                    LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;<br />
NEXT_SEC TOTAL_TIME B<br />
&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- -<br />
INTERVAL<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
  FAILURES<br />
&#8212;&#8212;&#8212;-<br />
WHAT<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
NLS_ENV<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
MISC_ENV                                                           INSTANCE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />
         1 SYS                            SYS<br />
SYS                                                                  27-DEC-11<br />
19:00:00          0 N<br />
trunc(SYSDATE+1/24,&#039;HH&#039;)</p>
<p>statspack.snap;<br />
NLS_LANGUAGE=&#039;AMERICAN&#039; NLS_TERRITORY=&#039;AMERICA&#039; NLS_CURRENCY=&#039;$&#039; NLS_ISO_CURRENC<br />
Y=&#039;AMERICA&#039; NLS_NUMERIC_CHARACTERS=&#039;.,&#039; NLS_DATE_FORMAT=&#039;DD-MON-RR&#039; NLS_DATE_LAN<br />
GUAGE=&#039;AMERICAN&#039; NLS_SORT=&#039;BINARY&#039;<br />
0102000202000000                                                          1</p>
<p><b>To change the snap interval one can execute dbms_job.interval in the example below it changes to collect every 1/2 hr</b><br />
SQL&gt; exec dbms_job.interval(1, &#039;trunc(SYSDATE+1/48,&#039;&#039;HH&#039;&#039;)&#039;);</p>
<p>PL/SQL procedure successfully completed.</p>
<p>SQL&gt; select * FROM User_jobs;</p>
<p>       JOB LOG_USER                       PRIV_USER<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
SCHEMA_USER                    LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212; &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;<br />
NEXT_SEC TOTAL_TIME B<br />
&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;- -<br />
INTERVAL<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
  FAILURES<br />
&#8212;&#8212;&#8212;-<br />
WHAT<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
NLS_ENV<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
MISC_ENV                                                           INSTANCE<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;-<br />
         1 SYS                            SYS<br />
SYS                                                                  27-DEC-11<br />
19:00:00          0 N<br />
trunc(SYSDATE+1/48,&#039;HH&#039;)</p>
<p>statspack.snap;<br />
NLS_LANGUAGE=&#039;AMERICAN&#039; NLS_TERRITORY=&#039;AMERICA&#039; NLS_CURRENCY=&#039;$&#039; NLS_ISO_CURRENC<br />
Y=&#039;AMERICA&#039; NLS_NUMERIC_CHARACTERS=&#039;.,&#039; NLS_DATE_FORMAT=&#039;DD-MON-RR&#039; NLS_DATE_LAN<br />
GUAGE=&#039;AMERICAN&#039; NLS_SORT=&#039;BINARY&#039;<br />
0102000202000000                                                          1</p>
<p><b>To schedule it through crontab:</b> One would need to invoke the package &#8220;statspack.snap&#8221; via SQL*Plus</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2011/12/29/how-to-schedule-a-snap-for-statspack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to delete or truncate Statspack data?</title>
		<link>http://blog.flimatech.com/2011/12/29/how-to-delete-or-truncate-statspack-data/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-delete-or-truncate-statspack-data</link>
		<comments>http://blog.flimatech.com/2011/12/29/how-to-delete-or-truncate-statspack-data/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 17:36:33 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[Statspack]]></category>
		<category><![CDATA[Tuning]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[statspack]]></category>
		<category><![CDATA[truncate]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1900</guid>
		<description><![CDATA[One can truncate data in STATSPACK or delete range of snaps stored. To truncate STATSPACK data Using $ORACLE_HOME/rdbms/admin/sptrunc.sql, one can truncate STATSPACK data. To run the script you will need to connect as PERFSTAT user. perfstat@TESTDB&#62; @?/rdbms/admin/sptrunc.sql Warning ~~~~~~~ Running sptrunc.sql removes ALL data from Statspack tables. You may wish to export the data before [...]]]></description>
			<content:encoded><![CDATA[<p>One can truncate data in STATSPACK or delete range of snaps stored.</p>
<p><b>To truncate STATSPACK data</b></p>
<p>Using $ORACLE_HOME/rdbms/admin/sptrunc.sql, one can truncate STATSPACK data.  To run the script you will need to connect as PERFSTAT user.</p>
<p>perfstat@TESTDB&gt; @?/rdbms/admin/sptrunc.sql</p>
<p>Warning<br />
~~~~~~~<br />
Running sptrunc.sql removes ALL data from Statspack tables.  You may<br />
wish to export the data before continuing.</p>
<p>About to Truncate Statspack Tables<br />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
If would like to exit WITHOUT truncating the tables, enter any text at the<br />
begin_or_exit prompt (e.g. &amp;&#039;exit&amp;&#039;), otherwise if you would like to begin<br />
the truncate operation, press </p>
<p>Enter value for begin_or_exit:</p>
<p><b>To delete STATSPACK data</b> &#8211; This will prompt for starting snap id and end snap id.<br />
One can run the following SQL that will show all the snap ids on the current instance.<br />
select s.snap_id<br />
     , to_char(s.snap_time,&amp;&#039; dd Mon YYYY HH24:mi:ss&amp;&#039;)    snap_date<br />
     , s.baseline<br />
     , s.snap_level                                      &#035;level&#035;<br />
     , di.host_name                                      host_name<br />
     , s.ucomment<br />
  from perfstat.stats$snapshot s<br />
     , perfstat.stats$database_instance di<br />
     , v$database v<br />
     , v$instance i<br />
 where s.dbid              = v.dbid<br />
   and di.dbid             = v.dbid<br />
   and s.instance_number   = i.instance_number<br />
   and di.instance_number  = i.instance_number<br />
   and di.startup_time     = s.startup_time<br />
 order by di.db_name, i.instance_name, s.snap_id<br />
/</p>
<p>   SNAP_ID SNAP_DATE             B      level<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8211; &#8212;&#8212;&#8212;-<br />
HOST_NAME<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
UCOMMENT<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
         1  27 Dec 2011 18:30:56            5<br />
MACHINE<br />
         2  27 Dec 2011 18:30:58            6<br />
MACHINE</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2011/12/29/how-to-delete-or-truncate-statspack-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to gather stats without histograms?</title>
		<link>http://blog.flimatech.com/2011/12/29/1897/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=1897</link>
		<comments>http://blog.flimatech.com/2011/12/29/1897/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 17:34:10 +0000</pubDate>
		<dc:creator>Amin Jaffer</dc:creator>
				<category><![CDATA[Statistics]]></category>
		<category><![CDATA[Tuning]]></category>
		<category><![CDATA[gather]]></category>
		<category><![CDATA[histogram]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[method_opt]]></category>
		<category><![CDATA[no]]></category>
		<category><![CDATA[opt]]></category>
		<category><![CDATA[stats]]></category>
		<category><![CDATA[without]]></category>

		<guid isPermaLink="false">http://blog.flimatech.com/?p=1897</guid>
		<description><![CDATA[When passing method_opt as &#039;FOR ALL COLUMNS SIZE 1&#039;, it means no histogram is collected for columns on the table(s). exec dbms_stats.gather_schema_stats(&#039;SCOTT&#039;, method_opt=&#62;&#039;FOR ALL COLUMNS SIZE 1&#039;); One can find the default value by executing as follows: select DBMS_STATS.GET_PARAM(&#039;METHOD_OPT&#039;) from dual;]]></description>
			<content:encoded><![CDATA[<p>When passing method_opt as &#039;FOR ALL COLUMNS SIZE 1&#039;, it means no histogram is collected for columns on the table(s).</p>
<p>exec dbms_stats.gather_schema_stats(&#039;SCOTT&#039;, method_opt=&gt;&#039;FOR ALL COLUMNS SIZE 1&#039;);</p>
<p>One can find the default value by executing as follows:<br />
select DBMS_STATS.GET_PARAM(&#039;METHOD_OPT&#039;) from dual;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flimatech.com/2011/12/29/1897/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

