<?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>Database.fi &#187; dbms_job</title>
	<atom:link href="http://www.database.fi/tag/dbms_job/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.database.fi</link>
	<description>Database Performance &#38; Disaster Solutions</description>
	<lastBuildDate>Tue, 25 Oct 2011 07:43:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Installing and configuring Statspack to Oracle (dbms_job configuration)</title>
		<link>http://www.database.fi/2010/03/installing-and-configuring-statspack-to-oracle/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=installing-and-configuring-statspack-to-oracle</link>
		<comments>http://www.database.fi/2010/03/installing-and-configuring-statspack-to-oracle/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 15:58:46 +0000</pubDate>
		<dc:creator>pparkko</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle Jobs]]></category>
		<category><![CDATA[Statspack]]></category>
		<category><![CDATA[dbms_ijob]]></category>
		<category><![CDATA[dbms_job]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[oracle job]]></category>
		<category><![CDATA[Oracle Performance Tuning]]></category>
		<category><![CDATA[Performance Tuning]]></category>

		<guid isPermaLink="false">http://www.database.fi/?p=55</guid>
		<description><![CDATA[I was asked to provide instructions on how to install and configure Statspack into Oracle so here goes.
The statspack scripts can be found from under this directory structure:
$Oracle_home/rdbms/admin

The installation needs to be run as SYS user.
Basic installation is done simply by running this script:
@?/rdbms/admin/spcreate.sql

This installs the Statspack engine &#038; tables to database.
You can (if you [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to provide instructions on how to install and configure Statspack into Oracle so here goes.</p>
<p>The statspack scripts can be found from under this directory structure:<br />
<code>$Oracle_home/rdbms/admin<br />
</code></p>
<p>The installation needs to be run as SYS user.</p>
<p>Basic installation is done simply by running this script:<br />
<code>@?/rdbms/admin/spcreate.sql<br />
</code></p>
<p>This installs the Statspack engine &#038; tables to database.</p>
<p>You can (if you want) automate the snap creation with this script:<br />
<code>@?/rdbms/admin/spauto.sql<br />
</code><br />
This script takes snaps every hour starting from the next hour.</p>
<p>You can modify this script to make another kind of scheduling.<br />
For example if you want to take snaps every half an hour, you need to modify:<br />
<code>"sysdate+1/24" => "sysdate+1/48"</p>
<p>dbms_job.submit(:jobno, 'statspack.snap;', trunc(sysdate+1/24,'HH'), 'trunc(SYSDATE+1/24,''HH'')', TRUE, :instno);<br />
</code><br />
=><br />
<code>dbms_job.submit(:jobno, 'statspack.snap;', trunc(sysdate+1/48,'HH'), 'trunc(SYSDATE+1/48,''HH'')', TRUE, :instno);<br />
</code></p>
<p>If you need to ie. change the currently running job interval, you need to find out the job number first.<br />
Connect as dba user to Oracle and run this query:<br />
<code><br />
select job, what, interval from dba_jobs;</p>
<p>       JOB<br />
----------<br />
WHAT<br />
-----------------------------<br />
INTERVAL<br />
-----------------------------<br />
        21<br />
statspack.snap;<br />
trunc(SYSDATE+1/24,'HH')</code></p>
<p>So the statspack.snap is run every hour and job number is 21. Fine.<br />
Let&#8217;s say that we need to run it every half an hour.<br />
We need to change the interval to: 1/48.</p>
<p>You can update the job interval like this. You can set is as the job owner with this syntax:<br />
<code>exec dbms_job.interval(21,'TRUNC(SYSDATE+1/48,''HH'')');</p>
<p>PL/SQL procedure successfully completed.<br />
</code></p>
<p>Or as another user with DBA privileges:<br />
<code>SQL> show user<br />
USER is "SYS"<br />
SQL> exec dbms_ijob.interval(21,'TRUNC(SYSDATE+1/48,''HH'')');</p>
<p>PL/SQL procedure successfully completed.<br />
</code></p>
<p><em>Please note: there are two single quotes &#8216; around HH, not one double-quote &#8220;.<br />
</em></p>
<p>Also you could remove the job with:<br />
<code>exec dbms_job.remove(21);</code></p>
<p>and re-create it with:<br />
<code><br />
variable jobno number;<br />
variable instno number;<br />
begin<br />
  select instance_number into :instno from v$instance;<br />
  dbms_job.submit(:jobno, 'statspack.snap;', trunc(sysdate+1/48,'HH'), 'trunc(SYSDATE+1/48,''HH'')', TRUE, :instno);<br />
  commit;<br />
end;<br />
/<br />
</code></p>
<p>You should try that the job runs now.</p>
<p>Run as the job owner:<br />
<code>SQL> exec dbms_job.run(21);</p>
<p>PL/SQL procedure successfully completed.<br />
</code><br />
Run as a DBA user:<br />
<code>SQL> exec dbms_ijob.run(21);</p>
<p>PL/SQL procedure successfully completed.</code></p>
<p>You can check when the next scheduled job run is:<br />
<code><br />
SQL> select job, what, interval, to_char(next_date, 'DD.MM.YYYY HH24:MI:SS') from dba_jobs where job=21;</p>
<p>       JOB<br />
----------<br />
WHAT<br />
-------------------------------------<br />
INTERVAL<br />
-------------------------------------<br />
TO_CHAR(NEXT_DATE,'<br />
-------------------<br />
        21<br />
statspack.snap;<br />
TRUNC(SYSDATE+1/48,'HH')<br />
29.03.2010 11:00:00</code></p>
<p>Statspack was introduced in Oracle 9i and it is still an usable tool in current Oracle version of 11.2.<br />
AWR is superior technology compared to Statspack, but for many purposes Statspack still holds its place.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.database.fi/2010/03/installing-and-configuring-statspack-to-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

