<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Thinking Out Loud</title>
	<atom:link href="https://mdinh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://mdinh.wordpress.com</link>
	<description>Michael Dinh, Oracle DBA</description>
	<lastBuildDate>Thu, 26 Jan 2012 14:02:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mdinh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s-ssl.wordpress.com/i/buttonw-com.png</url>
		<title>Thinking Out Loud</title>
		<link>https://mdinh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://mdinh.wordpress.com/osd.xml" title="Thinking Out Loud" />
	<atom:link rel='hub' href='https://mdinh.wordpress.com/?pushpress=hub'/>
		<item>
		<title>My Bi-directional Replication Using GoldenGate Adventure, Ep1</title>
		<link>https://mdinh.wordpress.com/2012/01/21/my-bi-directional-replication-using-goldengate-adventure-ep1/</link>
		<comments>https://mdinh.wordpress.com/2012/01/21/my-bi-directional-replication-using-goldengate-adventure-ep1/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 16:14:48 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[GoldenGate]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=587</guid>
		<description><![CDATA[I want to share my beginning adventure for configuring bi-directional replication using GoldenGate. GoldenGate installation will not be covered since it is well documented and blogged about in many sites. Note: When you see GGSCI&#62;, this means the command was executed in GG Command Interpreter and not OS shell (&#62;). Prerequisite: Database in Archive Mode,  alter [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=587&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I want to share my beginning adventure for configuring bi-directional replication using GoldenGate.</p>
<p>GoldenGate installation will not be covered since it is well documented and blogged about in many sites.</p>
<p>Note: When you see GGSCI&gt;, this means the command was executed in GG Command Interpreter and not OS shell (&gt;).</p>
<p><strong>Prerequisite:</strong></p>
<p>Database in Archive Mode,  alter database add supplemental log data, GoldenGate installed at source and target.</p>
<p><strong>Parameter file:</strong></p>
<p>Changes made based on GG documentation</p>
<pre>undo_retention=86400
recyclebin=off</pre>
<p><strong>Environment:</strong></p>
<p>Using an OBEY script with ENCRYPTED password to determine environment. More on this later.</p>
<pre>&gt; cd /u01/app/ggs/
&gt; ggsci
Oracle GoldenGate Command Interpreter for Oracle
<span style="text-decoration:underline;color:#ff0000;"><strong>Version 11.1.1.1.2 OGGCORE_11.1.1.1.2_PLATFORMS_111004.2100</strong></span>
<span style="text-decoration:underline;color:#ff0000;"><strong>Solaris, x64, 64bit (optimized)</strong></span>, Oracle 11g on Oct 4 2011 23:54:06
Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
GGSCI 1&gt; obey <span style="color:#000000;">chk_version.obey</span>
GGSCI 2&gt; dblogin userid gguser, password<span style="text-decoration:underline;"><span style="color:#ff0000;text-decoration:underline;"> AACAAAAAAAAAAAJAXHHGIEDCVGTJXDDEPHZEFEMDPEEGEJMH</span></span>, encryptkey key1
Successfully logged into database.
GGSCI 3&gt; versions
<strong><span style="text-decoration:underline;color:#ff0000;">Operating System:</span></strong>
SunOS
Version Generic_141445-09, Release 5.10
Node: &lt;hostname&gt;
Machine: i86pc
<span style="text-decoration:underline;color:#ff0000;"><strong>Database:</strong></span>
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
GGSCI 4&gt; exit</pre>
<p><strong>SYSDBA Privilege:</strong></p>
<p>A SQL script was failing because there was no SYSDBA privilege and I was connected as &#8220;/ as sysdba&#8221;. It turns out that SYS was not in v$pwfile_users.</p>
<p>Most of the SQL used sys_context(&#8216;userenv&#8217;,'ISDBA&#8217;), but one was using v$pwfile_users.</p>
<pre>&gt; grep -i PWFILE_USERS *.sql
marker_remove.sql: FROM v$pwfile_users
&gt; grep ISDBA *.sql
ddl_remove.sql: SELECT sys_context('userenv','ISDBA') INTO :isdba FROM DUAL; -- use network method for isdba determination
ddl_setup.sql:-- FP 17971: use ISDBA as well to determine dba privs
ddl_setup.sql: SELECT sys_context('userenv','ISDBA') INTO :isdba FROM DUAL; -- use network method for isdba determination
remove_seq.sql: SELECT sys_context('userenv','ISDBA') INTO :isdba FROM DUAL; -- use network
sequence.sql: SELECT sys_context('userenv','ISDBA') INTO :isdba FROM DUAL; -- use network method for isdba determination</pre>
<p><strong>CREATE USER (gguser) with DDL Replication Configuration:</strong></p>
<pre>GRANT CREATE SESSION,ALTER SESSION to gguser identified by oracle_4u;
GRANT CONNECT,SELECT ANY DICTIONARY,FLASHBACK ANY TABLE,SELECT ANY TABLE to gguser;
GRANT SELECT on dba_clusters to gguser;
GRANT EXECUTE on DBMS_FLASHBACK to gguser;
GRANT SELECT ANY TRANSACTION to gguser;
GRANT EXECUTE on utl_file TO gguser;
EXEC dbms_goldengate_auth.grant_admin_privilege('gguser');
@@sequence
@@marker_setup.sql
@@ddl_setup.sql
@@role_setup.sql
@@ddl_enable.sql
@@ddl_pin gguser
alter user gguser default tablespace ggs_data;
revoke unlimited tablespace from gguser;
alter user gguser quota unlimited on ggs_data;</pre>
<p>No DBA role was granted to GGUSER and it turns out that GGUSER had DBA role from marker_setup.sql: GRANT CONNECT, RESOURCE, DBA TO &amp;gg_user;</p>
<p><strong>Create ENCKEYS file in GG_HOME:</strong></p>
<p>ENCKEYS is a file containing key values used to encrypt password. In the example: keygen is used to create 2 keys having 128 bit.</p>
<pre>keygen 128 2 &gt; ENCKEYS</pre>
<p><strong>Add KeyName to ENCKEYS  file:</strong></p>
<p>Open ENCKEYS to add KeyName. You can provide any KeyName for the KeyValue. In the example, the KeyValue were named key1 and key2.</p>
<pre>## KeyName KeyValue
<span style="text-decoration:underline;color:#ff0000;">key1</span> 0x59038C335C69746FE0CA751368AB294E
key2 0x38374124C2D3AD74DFB443065D08160F</pre>
<p><strong>Generate Encrypted Password:</strong></p>
<pre>GGSCI&gt; encrypt password oracle_4u, encryptkey <span style="text-decoration:underline;"><span style="color:#ff0000;text-decoration:underline;">key1</span></span>
<span style="text-decoration:underline;"><span style="color:#ff0000;text-decoration:underline;">AACAAAAAAAAAAAJAXHHGIEDCVGTJXDDEPHZEFEMDPEEGEJMH</span></span></pre>
<p><strong>Test Encrypted Password:</strong></p>
<p><span style="color:#000000;">It&#8217;s now possible to use encrypted versus plain text password.</span></p>
<pre>GGSCI 1&gt; dblogin userid gguser, password oracle_4u
Successfully logged into database.
GGSCI 2&gt; dblogin userid gguser, password AACAAAAAAAAAAAJAXHHGIEDCVGTJXDDEPHZEFEMDPEEGEJMH,encryptkey <span style="text-decoration:underline;"><span style="color:#ff0000;text-decoration:underline;">key1</span></span>
Successfully logged into database.</pre>
<p><strong>OBEY script:</strong></p>
<p>In GoldenGate, an obey script is equivalent to a SQL script. One caveat is when an obey script calls another obey script, <span style="text-decoration:underline;"><span style="color:#ff0000;text-decoration:underline;">allownested</span></span>  must be used.</p>
<p>Here is an example of a nested obey script.</p>
<pre>&gt; cat add_config_ggs01.obey
dblogin userid gguser, password AACAAAAAAAAAAAJAXHHGIEDCVGTJXDDEPHZEFEMDPEEGEJMH, encryptkey key1
<span style="text-decoration:underline;"><span style="color:#ff0000;text-decoration:underline;">allownested</span></span>
versions
obey add_eggs01.obey
obey add_rggs02.obey
exit</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/587/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/587/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/587/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/587/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/587/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/587/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/587/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/587/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/587/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/587/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/587/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/587/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/587/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/587/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=587&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2012/01/21/my-bi-directional-replication-using-goldengate-adventure-ep1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Rotate Alert Log 11g</title>
		<link>https://mdinh.wordpress.com/2012/01/19/rotate-alert-log-11g/</link>
		<comments>https://mdinh.wordpress.com/2012/01/19/rotate-alert-log-11g/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 05:14:58 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=581</guid>
		<description><![CDATA[Tested on Solaris 10 &#62; cat rotate_alert.sh #!/bin/sh DN=`dirname $0` BN=`basename $0` . /home/oracle/.common.conf &#62; /dev/null month=`date &#8220;+%m&#8221;` for sid in `ps -eo args&#124;grep ora_smon&#124;grep -v grep&#124;awk -F_ &#8216;{print $3}&#8217;` do ORACLE_SID=$sid . oraenv diag_trace=`$ORACLE_HOME/bin/sqlplus -SL / &#60;&#60;EOF set echo off ver off feedb off head off pages 0 select value from v\\$diag_info where name=&#8217;Diag [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=581&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tested on Solaris 10</p>
<p>&gt; cat rotate_alert.sh<br />
#!/bin/sh</p>
<p>DN=`dirname $0`<br />
BN=`basename $0`</p>
<p>. /home/oracle/.common.conf &gt; /dev/null<br />
month=`date &#8220;+%m&#8221;`<br />
for sid in `ps -eo args|grep ora_smon|grep -v grep|awk -F_ &#8216;{print $3}&#8217;`<br />
do<br />
ORACLE_SID=$sid<br />
. oraenv<br />
diag_trace=`$ORACLE_HOME/bin/sqlplus -SL / &lt;&lt;EOF<br />
set echo off ver off feedb off head off pages 0<br />
select value from v\\$diag_info where name=&#8217;Diag Trace&#8217;;<br />
exit;<br />
EOF<br />
`<br />
alert_log=$diag_trace/alert_$sid.log<br />
mv $alert_log $alert_log.$month<br />
gzip -f $alert_log.$month<br />
touch ${alert_log}<br />
done<br />
exit</p>
<p>NOTE: there is a back-tick (`) in the line after EOF</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/581/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/581/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/581/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=581&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2012/01/19/rotate-alert-log-11g/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Happy New Year</title>
		<link>https://mdinh.wordpress.com/2011/12/31/happy-new-year/</link>
		<comments>https://mdinh.wordpress.com/2011/12/31/happy-new-year/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 18:07:37 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=560</guid>
		<description><![CDATA[An amazing photo at 500px: http://500px.com/photo/4039804<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=560&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An amazing photo at 500px: <a href="http://500px.com/photo/4039804">http://500px.com/photo/4039804</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/560/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/560/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/560/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=560&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/12/31/happy-new-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>datapump transform</title>
		<link>https://mdinh.wordpress.com/2011/12/14/datapump-transform/</link>
		<comments>https://mdinh.wordpress.com/2011/12/14/datapump-transform/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 03:36:52 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=545</guid>
		<description><![CDATA[I know there are many blogs out there on datapump; however, I wanted to just to create a quick post on parallel datapump and transform. The requirement is to parallel export and import and to migrate indexes to a new tablespace as part of a DW migration. Export parameter: DIRECTORY=data_pump_local DUMPFILE=mdinh%U.dmp SCHEMAS=mdinh PARALLEL=12 METRICS=y LOGFILE=expdp_mdinh.log [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=545&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I know there are many blogs out there on datapump; however, I wanted to just to create a quick post on parallel datapump and transform.</p>
<p>The requirement is to parallel export and import and to migrate indexes to a new tablespace as part of a DW migration.</p>
<p><strong>Export parameter:</strong></p>
<pre>DIRECTORY=data_pump_local
DUMPFILE=mdinh%U.dmp
SCHEMAS=mdinh
PARALLEL=12
METRICS=y
LOGFILE=expdp_mdinh.log
EXCLUDE=grant,statistics
REUSE_DUMPFILES=Y
FLASHBACK_SCN=10535801779818</pre>
<p><strong>Import parameter (NO TRANSFORM):</strong></p>
<pre>DIRECTORY=data_pump_local
DUMPFILE=mdinh%U.dmp
SCHEMAS=mdinh
PARALLEL=12
METRICS=y
LOGFILE=impdp_mdinh.log
INCLUDE=constraint,index
SQLFILE=mdinh_notransform.sql</pre>
<p><strong>&gt; cat mdinh_notransform.sql</strong></p>
<pre>-- CONNECT OPS$ORACLE
ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
-- new object type path: SCHEMA_EXPORT/TABLE/INDEX/INDEX
-- CONNECT MDINH
CREATE UNIQUE INDEX "MDINH"."PKP" ON "MDINH"."P" ("ID")
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 TABLESPACE "USER_DATA" PARALLEL 1 ;
ALTER INDEX "MDINH"."PKP" NOPARALLEL;
<span style="text-decoration:underline;"><span style="color:#000080;text-decoration:underline;">CREATE INDEX "MDINH"."X" ON "MDINH"."F" ("ID")</span></span>
<span style="text-decoration:underline;"><span style="color:#000080;text-decoration:underline;"> PCTFREE 10 INITRANS 2 MAXTRANS 255</span></span>
 <strong><span style="text-decoration:underline;color:#ff0000;">STORAGE( INITIAL 1048576)</span></strong>
<span style="text-decoration:underline;"><span style="color:#000080;text-decoration:underline;"> TABLESPACE "USER_DATA" PARALLEL 1 ;</span></span>
ALTER INDEX "MDINH"."X" NOPARALLEL;
-- new object type path: SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT OPS$ORACLE
<span style="text-decoration:underline;">ALTER TABLE "MDINH"."P" ADD CONSTRAINT "PKP" PRIMARY KEY ("ID") RELY USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 <span style="text-decoration:underline;color:#ff0000;"> TABLESPACE "USER_DATA" ENABLE;</span></span>
-- new object type path: SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
ALTER TABLE "MDINH"."F" ADD CONSTRAINT "F1" FOREIGN KEY ("ID")
 REFERENCES "MDINH"."P" ("ID") RELY DISABLE;</pre>
<p><strong>Import parameter (TRANSFORM):</strong></p>
<pre>DIRECTORY=data_pump_local
DUMPFILE=mdinh%U.dmp
SCHEMAS=mdinh
PARALLEL=12
METRICS=y
LOGFILE=impdp_mdinh.log
INCLUDE=constraint,index
SQLFILE=mdinh_transform.sql
TRANSFORM=STORAGE:n:index
TRANSFORM=STORAGE:n:constraint
REMAP_TABLESPACE=user_data:user_index</pre>
<p><strong>&gt; cat mdinh_transform.sql</strong></p>
<pre>-- CONNECT OPS$ORACLE
ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
-- new object type path: SCHEMA_EXPORT/TABLE/INDEX/INDEX
-- CONNECT MDINH
<span style="text-decoration:underline;"><span style="color:#000080;text-decoration:underline;">CREATE UNIQUE INDEX "MDINH"."PKP" ON "MDINH"."P" ("ID")</span></span>
<span style="text-decoration:underline;"><span style="color:#000080;text-decoration:underline;"> PCTFREE 10 INITRANS 2 MAXTRANS 255</span></span>
<span style="text-decoration:underline;"> TABLESPACE "<span style="color:#ff0000;text-decoration:underline;">USER_INDEX</span>"<span style="color:#000080;text-decoration:underline;"> PARALLEL 1</span> ;</span>
ALTER INDEX "MDINH"."PKP" NOPARALLEL;
CREATE INDEX "MDINH"."X" ON "MDINH"."F" ("ID")
 PCTFREE 10 INITRANS 2 MAXTRANS 255
 TABLESPACE "<span style="text-decoration:underline;color:#ff0000;">USER_INDEX</span>" PARALLEL 1 ;
ALTER INDEX "MDINH"."X" NOPARALLEL;
-- new object type path: SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
-- CONNECT OPS$ORACLE
<span style="text-decoration:underline;">ALTER TABLE "MDINH"."P" ADD CONSTRAINT "PKP" PRIMARY KEY ("ID") RELY USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 <span style="color:#ff0000;text-decoration:underline;"> TABLESPACE "<span style="text-decoration:underline;">USER_INDEX</span>" ENABLE;</span></span>
-- new object type path: SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
ALTER TABLE "MDINH"."F" ADD CONSTRAINT "F1" FOREIGN KEY ("ID")
 REFERENCES "MDINH"."P" ("ID") RELY DISABLE;</pre>
<p>Did you notice the storage clause in the mdinh_notransform.sql?</p>
<pre></pre>
<p>REFERENCE: <a href="http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_import.htm#SUTIL939" target="_blank">Data Pump Import: TRANSFORM</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/545/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/545/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/545/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/545/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/545/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/545/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/545/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/545/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=545&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/12/14/datapump-transform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>11.2.0.3 Silent Install and Database Creation using OMF</title>
		<link>https://mdinh.wordpress.com/2011/10/28/11-2-0-3-silent-install-and-database-creation-using-omf/</link>
		<comments>https://mdinh.wordpress.com/2011/10/28/11-2-0-3-silent-install-and-database-creation-using-omf/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 02:06:11 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=525</guid>
		<description><![CDATA[Performing Silent Install Operating System: &#62; uname -an SunOS &#60;hostname&#62; 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-880 oraInst.loc: &#62; cat /var/opt/oracle/oraInst.loc inventory_loc=/u01/app/11.2.0.3/oraInventory inst_group=dba Response File: &#62; cat /home/mdinh/ora_stage/11.2.0.3/patchset/database/response/swonly.rsp #------------------------------------------------------------------------------ # Do not change the following system generated value. #------------------------------------------------------------------------------ oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0 oracle.install.option=INSTALL_DB_SWONLY UNIX_GROUP_NAME=dba INVENTORY_LOCATION=/u01/app/11.2.0.3/oraInventory SELECTED_LANGUAGES=en ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.EEOptionsSelection=true # oracle.rdbms.partitioning:11.2.0.3.0 - Oracle Partitioning oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.3.0 oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba SECURITY_UPDATES_VIA_MYORACLESUPPORT=false [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=525&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Performing Silent Install</strong></p>
<p><strong>Operating System:</strong></p>
<pre>&gt; uname -an
SunOS &lt;hostname&gt; 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-880</pre>
<p><strong>oraInst.loc:</strong></p>
<pre>&gt; cat /var/opt/oracle/oraInst.loc
inventory_loc=/u01/app/11.2.0.3/oraInventory
inst_group=dba</pre>
<p><strong>Response File:</strong></p>
<pre>&gt; cat /home/mdinh/ora_stage/11.2.0.3/patchset/database/response/swonly.rsp
#------------------------------------------------------------------------------
# Do not change the following system generated value.
#------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=dba
INVENTORY_LOCATION=/u01/app/11.2.0.3/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=true
# oracle.rdbms.partitioning:11.2.0.3.0 - Oracle Partitioning
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.3.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES</pre>
<p><strong>Shell Script:</strong></p>
<pre>&gt; cat swonly.sh
#!/bin/sh -x
/home/mdinh/ora_stage/11.2.0.3/patchset/database/runInstaller -debug -silent -force -responseFile /home/mdinh/ora_stage/11.2.0.3/patchset/database/response/swonly.rsp
exit</pre>
<p><strong>Execute as Root:</strong></p>
<pre>/u01/app/oracle/product/11.2.0.3/dbhome_1/root.sh -bindir /opt/oracle/bin
Check /u01/app/oracle/product/11.2.0.3/dbhome_1/install/root_&lt;hostname&gt;_2011-10-26_11-33-40.log</pre>
<p><strong>Creating database using Oracle Managed Files (OMF)</strong></p>
<p>I have not been able to figure out why the directory for the database files  is created in UPPERCASE.</p>
<p>Hence, the pre-created directory will need to be in UPPERCASE as well.</p>
<p><strong>Create directories:</strong></p>
<pre>mkdir -p /u01/app/oracle/admin/DEVDB01/adump
mkdir -p /oracle/oradata/DEVDB01/arch/</pre>
<p><strong>Create init.ora:</strong></p>
<pre>&gt; cat initdevdb01.ora
audit_file_dest='/u01/app/oracle/admin/DEVDB01/adump'
audit_sys_operations=FALSE
audit_trail=NONE
compatible=11.2.0.3
control_files='/oracle/oradata/DEVDB01/control01.dbf','/oracle/oradata/DEVDB01/control02.dbf'
db_block_size=8192
db_create_file_dest='/oracle/oradata'
db_create_online_log_dest_1='/oracle/oradata'
db_create_online_log_dest_2='/oracle/oradata'
db_name=devdb01
diagnostic_dest='/u01/app/oracle'
fast_start_mttr_target=300
job_queue_processes=20
log_archive_dest_1='LOCATION=/oracle/oradata/DEVDB01/arch'
log_archive_format='arc_%d_%t_%r_%s.dbf'
open_cursors=1000
pga_aggregate_target=1G
processes=200
remote_login_passwordfile=EXCLUSIVE
sec_case_sensitive_logon=FALSE
session_cached_cursors=500
sga_max_size=2G
sga_target=2G
timed_statistics=TRUE
undo_management=AUTO
undo_retention=60000
undo_tablespace=undotbs1
workarea_size_policy=AUTO</pre>
<p><strong>Create database:</strong></p>
<pre>startup nomount;
create database
maxlogfiles 8
maxlogmembers 4
maxdatafiles 1024
character set AL32UTF8
national character set AL16UTF16
logfile group 1 size 256M,group 2 size 256M,group 3 size 256M,group 4 size 256M
default temporary tablespace temp tempfile size 1024M
undo tablespace undotbs1 datafile size 1024M;

@?/rdbms/admin/catalog.sql;
@?/rdbms/admin/catproc.sql;
@?/rdbms/admin/catblock.sql;
@?/rdbms/admin/catoctk.sql;
@?/rdbms/admin/catio.sql
@?/rdbms/admin/dbmsiotc.sql
@?/rdbms/admin/dbmsotrc.sql
@?/rdbms/admin/dbmspool.sql
@?/rdbms/admin/userlock.sql

shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
conn system
@?/sqlplus/admin/pupbld.sql</pre>
<p><strong>Create and Set DEFAULT tablespace:</strong></p>
<pre>CREATE TABLESPACE user_data DATAFILE SIZE 256M AUTOEXTEND ON NEXT 256M MAXSIZE 8G;
ALTER DATABASE DEFAULT TABLESPACE user_data;

COLUMN property_name FORMAT A30
COLUMN property_value FORMAT A30
COLUMN description FORMAT A50
SET LINESIZE 200
SELECT * FROM database_properties WHERE property_name like '%TABLESPACE';

SQL&gt; SELECT * FROM database_properties WHERE property_name like '%TABLESPACE';

PROPERTY_NAME                  PROPERTY_VALUE                 DESCRIPTION
------------------------------ ------------------------------ --------------------------------------------------
DEFAULT_TEMP_TABLESPACE        TEMP                           Name of default temporary tablespace
DEFAULT_PERMANENT_TABLESPACE   USER_DATA                      Name of default permanent tablespace</pre>
<p><strong>Directory Structures:</strong></p>
<pre>&gt; ls -l /oracle/oradata/DEVDB01/
total 68432
drwxr-xr-x   2 oracle   dba         1024 Oct 27 09:03 arch
-rw-r-----   1 oracle   dba      17481728 Oct 27 18:57 control01.dbf
-rw-r-----   1 oracle   dba      17481728 Oct 27 18:57 control02.dbf
drwxr-x---   2 oracle   dba         1024 Oct 27 09:42 datafile
drwxr-x---   2 oracle   dba         1024 Oct 26 13:41 onlinelog</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/525/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/525/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/525/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/525/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/525/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/525/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/525/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/525/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/525/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/525/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/525/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/525/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/525/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/525/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=525&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/10/28/11-2-0-3-silent-install-and-database-creation-using-omf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Shell and SQL Script</title>
		<link>https://mdinh.wordpress.com/2011/10/16/shell-and-sql-script/</link>
		<comments>https://mdinh.wordpress.com/2011/10/16/shell-and-sql-script/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 22:36:36 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=518</guid>
		<description><![CDATA[A quick note on separating SQL from shell script. If I have a shell script name longops.sh, then it will call longops.sql. Don&#8217;t embed SQL in shell script so that SQL script can be executed independently. &#62; cat longops.sh #!/bin/sh . /home/oracle/.common.conf &#62; /dev/null DN=`dirname $0` BN=`basename $0` sql=`echo $BN&#124;cut -d'.' -f1`.sql for sid in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=518&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A quick note on separating SQL from shell script.</p>
<p>If I have a shell script name longops.sh, then it will call longops.sql.</p>
<p>Don&#8217;t embed SQL in shell script so that SQL script can be executed independently.</p>
<pre>&gt; cat longops.sh
#!/bin/sh
. /home/oracle/.common.conf &gt; /dev/null
DN=`dirname $0`
BN=`basename $0`

sql=`echo $BN|cut -d'.' -f1`.sql
for sid in `ps -eo args|grep ora_smon|grep -v grep|awk -F_ '{print $3}'`
do
  OUTF=/tmp/longops.${sid}.html
  rm -f $OUTF
  ORACLE_SID=$sid
  . oraenv
  $ORACLE_HOME/bin/sqlplus -SL &gt; /dev/null / &lt;&lt; END
    spool $OUTF
    prompt From: oracle@mail.com
    prompt To: dba@mail.com
    prompt Subject: WARNING ${BN}: $ORACLE_SID - SQL running over one hour
    prompt Content-type: text/html
    prompt MIME-Version: 1.0
    set markup html on entmap off table 'BORDER="2"'
    @${sql}
    spool off
    exit
END
  if [ "$?" -ne "0" ]; then
    mailx -s "FAILED: $BN $*" $EMAIL &lt; /dev/null
  exit 1
  fi
  if [ `grep -ic MACHINE $OUTF` != 0 ]; then
    /usr/sbin/sendmail -t &lt; $OUTF
  fi
done
exit

&gt; cat longops.sql
ALTER SESSION SET NLS_DATE_FORMAT='Dy, DD-Mon-YYYY HH24:MI:SS';
SELECT s.sid, s.serial#,
       s.username,  s.osuser, s.machine, s.program,
       s.sql_id, s.sql_exec_start, s.logon_time,
       ROUND (s.last_call_et/3600,3) last_call_hr,
       ROUND ((SYSDATE-s.SQL_EXEC_START)*24,3) exec_start_hr,
       CASE WHEN s.state != 'WAITING' THEN 'WORKING' ELSE 'WAITING' END AS state,
       CASE WHEN s.state != 'WAITING' THEN 'On CPU / runqueue' ELSE event END AS sw_event
FROM   v$session s
WHERE  s.type = 'USER' AND s.status = 'ACTIVE' AND ROUND (s.last_call_et/3600)&gt;1
ORDER BY s.last_call_et DESC;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/518/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/518/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/518/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=518&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/10/16/shell-and-sql-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Create Standby Database from Active Database</title>
		<link>https://mdinh.wordpress.com/2011/10/08/create-standby-database-from-active-database/</link>
		<comments>https://mdinh.wordpress.com/2011/10/08/create-standby-database-from-active-database/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 14:45:15 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=497</guid>
		<description><![CDATA[This is just another post on how to create standby database from active database. By the way, I do love Oracle&#8217;s technology most of the time. This option was primarily chosen because the database size was ~400GB and there is no storage available to create backup for standby database. The process took almost 6 hours [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=497&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is just another post on how to create standby database from active database. By the way, I do love Oracle&#8217;s technology most of the time.</p>
<p>This option was primarily chosen because the database size was ~400GB and there is no storage available to create backup for standby database.</p>
<p>The process took almost 6 hours and was running while I was sleeping <img src='https://s-ssl.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre>Recovery Manager: Release 11.2.0.2.0 - Production on Fri Oct 7 21:49:57 2011
Finished Duplicate Db at 08-OCT-2011 03:31:22</pre>
<p><strong>Configuration:</strong></p>
<pre><span style="text-decoration:underline;">PRIMARY pfile</span>
&gt; more initdb08.ora
ifile=/home/oracle/pfile/initprodoltp_common.ora
_log_deletion_policy=ALL
event="10298 trace name context forever, level 32"
*.audit_file_dest="/u01/app/oracle/admin/db08/adump"
*.control_files=/oracle/oradata/db08/control01.ctl,/oracle/oradata/db08/control02.ctl
*.db_16k_cache_size=2G
*.db_32k_cache_size=2G
*.db_cache_size=2G
*.db_name="db08"
*.db_unique_name="lax_db08"
*.fal_client=lax_db08
*.fal_server=phx_db08
*.log_archive_config="DG_CONFIG=(lax_db08,phx_db08)"
*.log_archive_dest_1="LOCATION=/oracle/oradata/db08/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lax_db08"
*.log_archive_dest_2='SERVICE=phx_db08 LGWR ASYNC COMPRESSION=ENABLE REOPEN=15 NET_TIMEOUT=30 MAX_FAILURE=10 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=phx_db08'
*.shared_pool_reserved_size=512M
*.shared_pool_size=3G

<span style="text-decoration:underline;">STANDBY pfile</span>
&gt; more initdb08.ora
ifile=/home/oracle/pfile/initdr_common.ora
_log_deletion_policy=ALL
event="10298 trace name context forever, level 32"
*.audit_file_dest='/u01/app/oracle/admin/db08/adump'
*.control_files='/oracle/oradata/db08/control01.ctl','/oracle/oradata/db08/control02.ctl'#Restore Controlfile
*.db_16k_cache_size=512M
*.db_32k_cache_size=512M
*.db_cache_size=512M
*.db_name='db08'
*.db_unique_name='phx_db08'
*.fal_client='phx_db08'
*.fal_server='lax_db08'
*.log_archive_config='DG_CONFIG=(lax_db08,phx_db08)'
*.log_archive_dest_1='LOCATION=/oracle/oradata/db08/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=phx_db08'
*.log_archive_dest_2='SERVICE=lax_db08 LGWR ASYNC REOPEN=15 NET_TIMEOUT=30 MAX_FAILURE=10 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lax_db08'
*.shared_pool_size=256M

<span style="text-decoration:underline;">RMAN rcv</span>
&gt; cat db08.crstby.rcv
connect target;
connect auxiliary sys/password@phx_db08;
run {
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK;}
exit</pre>
<p>I manually created the parameter and password file at the STANDBY, opted not to use spfile.</p>
<p>From STANDBY, start listener and database (nomount)</p>
<p>From PRIMARY, execute RMAN using RCV</p>
<p>&gt; rman log=&#8217;db08.crstby.log&#8217; cmdfile=&#8217;db08.crstby.rcv&#8217;</p>
<p><strong>Snippets from the log file:</strong></p>
<pre>RMAN&gt; connect target;
2&gt; connect auxiliary *
3&gt; run {
4&gt; DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK;}
5&gt; exit
connected to target database: DB08 (DBID=1578229963)
connected to auxiliary database: DB08 (not mounted)

Starting Duplicate Db at 07-OCT-2011 21:50:02
using target database control file instead of recovery catalog
contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0.2/dbhome_1/dbs/orapwdb08' auxiliary format
 '/u01/app/oracle/product/11.2.0.2/dbhome_1/dbs/orapwdb08'   ;
}
executing Memory Script
contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/oracle/oradata/db08/control01.ctl';
   restore clone controlfile to  '/oracle/oradata/db08/control02.ctl' from
 '/oracle/oradata/db08/control01.ctl';
}
executing Memory Script
contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script
contents of Memory Script:
{
   set newname for tempfile  1 to
 "/oracle/oradata/db08/temp01.dbf";
   set newname for tempfile  2 to
 "/oracle/oradata/db08/temp02.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/oracle/oradata/db08/system01.dbf";
   set newname for datafile  2 to
 "/oracle/oradata/db08/undotbs01.dbf";
   set newname for datafile  3 to
 "/oracle/oradata/db08/sysaux01.dbf";
   set newname for datafile  4 to
 "/oracle/oradata/db08/undotbs02.dbf";
   set newname for datafile  5 to
 "/oracle/oradata/db08/ctxsys01.dbf";
~~~~
   backup as copy reuse
   datafile  1 auxiliary format
 "/oracle/oradata/db08/system01.dbf"   datafile
 2 auxiliary format
 "/oracle/oradata/db08/undotbs01.dbf"   datafile
 3 auxiliary format
 "/oracle/oradata/db08/sysaux01.dbf"   datafile
 4 auxiliary format
 "/oracle/oradata/db08/undotbs02.dbf"   datafile
 5 auxiliary format
 "/oracle/oradata/db08/ctxsys01.dbf"   datafile
   sql 'alter system archive log current';
}
executing Memory Script
Starting backup at 07-OCT-2011 21:50:45
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
Finished backup at 08-OCT-2011 03:24:14

sql statement: alter system archive log current

contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75240.dbf" auxiliary format
 "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75240.dbf"   archivelog like
 "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75241.dbf" auxiliary format
 "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75241.dbf"   archivelog like
 "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75242.dbf" auxiliary format
~~~
   catalog clone archivelog  "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75240.dbf";
   catalog clone archivelog  "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75241.dbf";
   catalog clone archivelog  "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75242.dbf";
   catalog clone archivelog  "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75243.dbf";
   catalog clone archivelog  "/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75244.dbf";
   switch clone datafile all;
}
executing Memory Script
Starting backup at 08-OCT-2011 03:24:21
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=75240 RECID=135728 STAMP=763941140
channel ORA_DISK_2: starting archived log copy
input archived log thread=1 sequence=75241 RECID=135729 STAMP=763941998
channel ORA_DISK_3: starting archived log copy
input archived log thread=1 sequence=75242 RECID=135730 STAMP=763942998
channel ORA_DISK_4: starting archived log copy
input archived log thread=1 sequence=75243 RECID=135731 STAMP=763944071
Finished backup at 08-OCT-2011 03:26:56

cataloged archived log
archived log file name=/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75240.dbf RECID=1 STAMP=763961217

cataloged archived log
archived log file name=/oracle/oradata/db08/arch/arc_5e11e0cb_1_598985931_75241.dbf RECID=2 STAMP=763961218
contents of Memory Script:
{
   set until scn  10533738778008;
   recover
   standby
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 08-OCT-2011 03:27:19
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
using channel ORA_AUX_DISK_3
using channel ORA_AUX_DISK_4

starting media recovery
media recovery complete, elapsed time: 00:03:08
Finished recover at 08-OCT-2011 03:30:49
Finished Duplicate Db at 08-OCT-2011 03:31:22

Recovery Manager complete.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/497/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=497&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/10/08/create-standby-database-from-active-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Renaming Interval Partitions</title>
		<link>https://mdinh.wordpress.com/2011/07/06/renaming-interval-partitions/</link>
		<comments>https://mdinh.wordpress.com/2011/07/06/renaming-interval-partitions/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 03:56:26 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=472</guid>
		<description><![CDATA[I wrote a stored procedure to RENAME USER system generated name for interval partition tables and LOCAL indexes. One pertinent information on &#62;&#62;Interval Partitioning Can only partition on one key column and must be NUMBER or DATE type &#62;&#62;NUMTOYMINTERVAL must resolve to the following values: &#8217;YEAR&#8217;,'MONTH&#8217; &#62;&#62;NUMTODSINTERVAL must resolve to the following values: &#8217;DAY&#8217;,'HOUR&#8217;,'MINUTE&#8217;,'SECOND&#8217; Download stored procedure and test [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=472&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wrote a stored procedure to RENAME USER system generated name for interval partition tables and LOCAL indexes.</p>
<p>One pertinent information on <a href="http://bit.ly/oNz3ky" target="_blank">&gt;&gt;Interval Partitioning</a></p>
<ul>
<li>Can only partition on one key column and must be NUMBER or DATE type</li>
</ul>
<p><a href="http://bit.ly/puFBz2" target="_blank">&gt;&gt;NUMTOYMINTERVAL</a> must resolve to the following values: &#8217;YEAR&#8217;,'MONTH&#8217;<br />
<a href="http://bit.ly/olQH14" target="_blank">&gt;&gt;NUMTODSINTERVAL</a> must resolve to the following values: &#8217;DAY&#8217;,'HOUR&#8217;,'MINUTE&#8217;,'SECOND&#8217;</p>
<p>Download stored procedure and test case <a href="http://bit.ly/qzvq23" target="_blank">&gt;&gt;interval_part.sql</a></p>
<p>System generated partitions.<br />
<a href="http://mdinh.files.wordpress.com/2011/07/p1.png"><img class="alignnone size-medium wp-image-479" title="System generated partition name" src="http://mdinh.files.wordpress.com/2011/07/p1.png?w=300&#038;h=246" alt="" width="300" height="246" /></a></p>
<p>Renamed partitions.<br />
<a href="http://mdinh.files.wordpress.com/2011/07/p2.png"><img class="alignnone size-medium wp-image-480" title="p2" src="http://mdinh.files.wordpress.com/2011/07/p2.png?w=300&#038;h=247" alt="" width="300" height="247" /></a></p>
<p>UPDATED: Add parameter p_table to package.</p>
<p>Update ONE table: exec mdinh_pkg.ren_interval_part(&#8216;day&#8217;);</p>
<p>Update ALL tables: exec mdinh_pkg.ren_interval_part;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/472/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/472/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/472/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=472&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/07/06/renaming-interval-partitions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>

		<media:content url="http://mdinh.files.wordpress.com/2011/07/p1.png?w=300" medium="image">
			<media:title type="html">System generated partition name</media:title>
		</media:content>

		<media:content url="http://mdinh.files.wordpress.com/2011/07/p2.png?w=300" medium="image">
			<media:title type="html">p2</media:title>
		</media:content>
	</item>
		<item>
		<title>fuser &#8211; identify users of files and devices</title>
		<link>https://mdinh.wordpress.com/2011/06/25/fuser-identify-users-of-files-and-devices/</link>
		<comments>https://mdinh.wordpress.com/2011/06/25/fuser-identify-users-of-files-and-devices/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 04:22:14 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=452</guid>
		<description><![CDATA[I learned about fuser when I had deleted 64GB file from /tmp but the space was never reclaimed. This shows you alert log is being opened in another session using vi. &#62; ll total 28992 drwxr-xr-x 25 root root 8192 Oct 23 2010 .. -rw-r--r-- 1 root sys 60 Oct 23 2010 csn.6249 -rw-r--r-- 1 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=452&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I learned about fuser when I had deleted 64GB file from /tmp but the space was never reclaimed.</p>
<p>This shows you alert log is being opened in another session using vi.</p>
<pre>&gt; ll
total 28992
drwxr-xr-x  25 root     root        8192 Oct 23  2010 ..
-rw-r--r--   1 root     sys           60 Oct 23  2010 csn.6249
-rw-r--r--   1 root     root          76 Oct 23  2010 iconf_entries.6185
drwxrwxrwt   2 root     root         117 Oct 29  2010 .oracle
drwxrwxrwt   4 root     sys          536 Jun 24 21:05 .
-rw-r-----   1 oracle   dba      14785325 Jun 24 21:05 alert_dbtest.log

&gt; ps -afe|grep alert_dbtest.log
  oracle 11589 16520   0 21:05:58 pts/8       0:00 grep alert_dbtest.log
  oracle 10555 19200   0 21:05:47 pts/6       0:01 vi alert_dbtest.log</pre>
<p>I am now going to delete alert log file.</p>
<pre>&gt; rm alert_dbtest.log

&gt; ll
total 112
drwxr-xr-x  25 root     root        8192 Oct 23  2010 ..
-rw-r--r--   1 root     sys           60 Oct 23  2010 csn.6249
drwxrwxrwt   2 root     root         117 Oct 29  2010 .oracle
drwxr-xr-x   2 oracle   dba          117 Nov  1  2010 hsperfdata_oracle
drwxrwxrwt   4 root     sys          463 Jun 24 21:06 .</pre>
<p>Who&#8217;s got the file opened?</p>
<pre>&gt; ps -o pid,args -p "$(fuser /tmp 2&gt;/dev/null)"
  PID COMMAND
10555 vi alert_dbtest.log
16520 -bash
19200 -bash

&gt; kill -9 10555</pre>
<p>Note:  tested on Solaris 10</p>
<p>Great reference here as well <a href="http://www.c0t0d0s0.org/archives/4228-Less-known-Solaris-Features-fuser.html" target="_blank">Less known Solaris Features: fuser</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/452/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=452&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/06/25/fuser-identify-users-of-files-and-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Have you seen ? CONSTRAINT_TYPE ?</title>
		<link>https://mdinh.wordpress.com/2011/06/15/have-you-seen-constraint_type/</link>
		<comments>https://mdinh.wordpress.com/2011/06/15/have-you-seen-constraint_type/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 04:00:10 +0000</pubDate>
		<dc:creator>mdinh</dc:creator>
				<category><![CDATA[11g]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://mdinh.wordpress.com/?p=442</guid>
		<description><![CDATA[When I was testing DBMS_REDEFINITION to convert a non-partitioned table to a partitioned table, I came across constraint_type &#8220;?&#8221; from TOAD. WTH! I have must have done something wrong. It turns out that TOAD used the following SQL to determine constraint_type and does not label non-constraints: SELECT CN.NAME constraint_name, c.type#, decode(c.type#, 1, 'Check', 2, 'Primary Key', [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=442&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When I was testing DBMS_REDEFINITION to convert a non-partitioned table to a partitioned table, I came across constraint_type &#8220;?&#8221; from TOAD.</p>
<p>WTH! I have must have done something wrong.</p>
<p>It turns out that TOAD used the following SQL to determine constraint_type and does not label non-constraints:</p>
<pre>SELECT CN.NAME constraint_name, c.type#, decode(c.type#, 1, 'Check', 2, 'Primary Key', 3, 'Unique Key',
       4, 'Referential Integrity', 5, 'Check Option on a View', 6, 'Read Only Option on a View', 7,'Check', '?') constraint_type
FROM   SYS.CDEF$ C, SYS.CON$ CN, SYS.OBJ$ O, SYS.USER$ U, SYS.CON$ RC, SYS.USER$ RU, SYS.OBJ$ RO
WHERE  C.CON# = CN.CON#
AND    C.OBJ# = O.OBJ#
AND    O.OWNER# = U.USER#
AND    C.RCON# = RC.CON#(+)
AND    RC.OWNER# = RU.USER#(+)
AND    C.ROBJ# = RO.OBJ#(+)
AND    U.NAME = 'SCOTT'
AND    O.NAME = 'SH'
AND    c.type# not in (8, 12)
order by 1;</pre>
<p>Notice how TOAD purposely left out  cdef$.type# 8 &amp; 12, but forgot about the others.</p>
<p>Querying dba_contraints shows different results:</p>
<pre>SQL&gt; select CONSTRAINT_NAME,CONSTRAINT_TYPE from dba_constraints where OWNER='SCOTT' and TABLE_NAME='SH';

no rows selected

SQL&gt;</pre>
<p>Here&#8217;s how I was able to find the definition for the various cdef$.type#</p>
<p>From ORCLE_HOME/rdbms/admin -</p>
<pre>&gt; grep 'cdef\$' *.sql
catmeta.sql:          oi.obj# = cdef$.enabled and
catmeta.sql:          bitand(cdef$.defer,8) = 8 and                  /* system generated */
catmeta.sql:          cdef$.type# = 3 and</pre>
<p>This hinted me to look at catmeta.sql and found this</p>
<pre>  type_num      number,                                  /* constraint type: */
                            /* 1 = table check, 2 = primary key, 3 = unique, */
                             /* 4 = referential, 5 = view with CHECK OPTION, */
                                                 /* 6 = view READ ONLY check */
               /* 7 - table check constraint associated with column NOT NULL */
                                   /* 8 - hash expressions for hash clusters */
                                         /* 9 - Scoped REF column constraint */
                                    /* 10 - REF column WITH ROWID constraint */
                                  /* 11 - REF/ADT column with NOT NULL const */
                                 /* 12 - Log Groups for supplemental logging */
                                    /* 14 - Primary key supplemental logging */
                                     /* 15 - Unique key supplemental logging */
                                    /* 16 - Foreign key supplemental logging */
                                     /* 17 - All column supplemental logging */</pre>
<p>Here is a little testing I did to confirm  cdef$.type# = 17 (All column supplemental logging)</p>
<pre>SQL&gt; SELECT CN.NAME constraint_name, c.type#, decode(c.type#, 1, 'Check', 2, 'Primary Key', 3, 'Unique Key',
  2         4, 'Referential Integrity', 5, 'Check Option on a View', 6, 'Read Only Option on a View', 7,'Check', '?') constraint_type
  3  FROM   SYS.CDEF$ C, SYS.CON$ CN, SYS.OBJ$ O, SYS.USER$ U, SYS.CON$ RC, SYS.USER$ RU, SYS.OBJ$ RO
  4  WHERE  C.CON# = CN.CON#
  5  AND    C.OBJ# = O.OBJ#
  6  AND    O.OWNER# = U.USER#
  7  AND    C.RCON# = RC.CON#(+)
  8  AND    RC.OWNER# = RU.USER#(+)
  9  AND    C.ROBJ# = RO.OBJ#(+)
 10  AND    U.NAME = 'SCOTT'
 11  AND    O.NAME = 'SH'
 12  AND    c.type# not in (8, 12)
 13  order by 1;

no rows selected

SQL&gt; alter table scott.sh add supplemental log data (all) columns;

Table altered.

SQL&gt; SELECT CN.NAME constraint_name, c.type#, decode(c.type#, 1, 'Check', 2, 'Primary Key', 3, 'Unique Key',
  2         4, 'Referential Integrity', 5, 'Check Option on a View', 6, 'Read Only Option on a View', 7,'Check', '?') constraint_type
  3  FROM   SYS.CDEF$ C, SYS.CON$ CN, SYS.OBJ$ O, SYS.USER$ U, SYS.CON$ RC, SYS.USER$ RU, SYS.OBJ$ RO
  4  WHERE  C.CON# = CN.CON#
  5  AND    C.OBJ# = O.OBJ#
  6  AND    O.OWNER# = U.USER#
  7  AND    C.RCON# = RC.CON#(+)
  8  AND    RC.OWNER# = RU.USER#(+)
  9  AND    C.ROBJ# = RO.OBJ#(+)
 10  AND    U.NAME = 'SCOTT'
 11  AND    O.NAME = 'SH'
 12  AND    c.type# not in (8, 12)
 13  order by 1;

CONSTRAINT_NAME                     TYPE# CONSTRAINT_TYPE
------------------------------ ---------- --------------------------------
SYS_C0010094                           17 ?

SQL&gt;</pre>
<p>Guess I can close the SR now.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mdinh.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mdinh.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mdinh.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mdinh.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mdinh.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mdinh.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mdinh.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mdinh.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mdinh.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mdinh.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mdinh.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mdinh.wordpress.com/442/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mdinh.wordpress.com/442/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mdinh.wordpress.com/442/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mdinh.wordpress.com&amp;blog=284246&amp;post=442&amp;subd=mdinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://mdinh.wordpress.com/2011/06/15/have-you-seen-constraint_type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/4d1ef2bcc7abd1b06749f347bfbc0add?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdinh</media:title>
		</media:content>
	</item>
	</channel>
</rss>
