<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>ORACLE: DBA's day out</title><description>A blog about Oracle administration and configuration.</description><managingEditor>noreply@blogger.com (Mohammad Hasan Shaharear)</managingEditor><pubDate>Mon, 8 Jun 2026 09:30:34 +0600</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">124</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://shaharear.blogspot.com/</link><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:subtitle>A blog about Oracle administration and configuration.</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Software How-To"/></itunes:category><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><title>TDE Part-2: Implement TDE Tablespace Encryption</title><link>http://shaharear.blogspot.com/2014/04/tde-part-2-implement-tde-tablespace.html</link><category>Oracle Basics</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Sat, 19 Apr 2014 20:14:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-9066210443438717350</guid><description>&lt;br /&gt;
In this part, we will implement TDE Tablespace Encryption. As TDE Tablespace Encryption have several major benefits over TDE Column Encryption ( Please read &lt;a href="http://shaharear.blogspot.com/2014/04/part-1-transparent-data-encryption-tde.html" target="_blank"&gt;Part-1&lt;/a&gt; for details ), we skip TDE column encryption and give our full focus on TDE Tablespace Encryption.&lt;br /&gt;
&lt;br /&gt;
In order to implement TDE tablespace encryption, your Oracle Database version must be 11g release 1 (11.1) or higher. If you wish to test the enhanced tablespace encryption features, Oracle Database 11g Release 2 (11.2) is required.&lt;br /&gt;
&lt;br /&gt;
TDE tablespace encryption will encrypting entire tablespaces. That means all objects stored in such tablespace will be 'By Default' encrypted. There is no restrictions to have encrypted and unencrypted tablespaces simultaneously in you database. You only encrypt those tablespaces which contain user/application data, system tablespaces must be remain as it is (i.e, unencrypted).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
How to Encrypt a Tablespace Using TDE&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;
Step 1 : Configure Oracle Wallet&lt;/h4&gt;
&lt;br /&gt;
Oracle Wallet is a secure password storage container which is placed outside of Oracle Database. To reduce the content of this post, we will give a brief configure of Oracle wallet here (if you have more interest please through&amp;nbsp;&lt;a href="http://shaharear.blogspot.com/2013/05/oracle-wallet-secure-external-password.html" target="_blank"&gt;this post&lt;/a&gt; for details). For TDE, oracle recommended to place the wallet outside of Oracle database though default wallet locations are inside database directories:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;$ORACLE_BASE/admin/DB_UNIQUE_NAME/wallet&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;$ORACLE_HOME/admin/DB_UNIQUE_NAME/wallet.&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
When selecting which wallet to use, TDE first try to use the wallet specified by the parameter &lt;i&gt;ENCRYPTION_WALLET_LOCATION&lt;/i&gt;. If the parameter is not set, then it looks the parameter &lt;i&gt;WALLET_LOCATION&lt;/i&gt;. If this is not set as well, then TDE looks for a wallet at the default database location which i mention above. There are several usages of Oracle Wallet, TDE is one of them. Oracle strongly recommends that you use a separate wallet to store TDE master encryption keys. To set-up a separate wallet, set the &lt;i&gt;ENCRYPTION_WALLET_LOCATION&lt;/i&gt; parameter in the sqlnet.ora file to point to the wallet used exclusively by TDE.&lt;br /&gt;
&lt;br /&gt;
We Like to put the wallet files outside of Oracle installation directories. Therefore we chose location '/u01/encryption_wallet/'. Now, add following lines to sqlnet.ora and save it.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;ENCRYPTION_WALLET_LOCATION= (SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/encryption_wallet)))&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;br /&gt;
&lt;h4&gt;
Step 2: Create an Oracle PKCS#12 standard wallet&amp;nbsp;&lt;/h4&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;Command: orapki wallet create -wallet '&lt;/i&gt;&lt;i&gt;/u01/encryption_wallet&lt;/i&gt;&lt;i&gt;' -pwd "oracle123"&lt;/i&gt;&lt;br /&gt;
This command creates a wallet file 'ewallet.p12' in specified location. The wallet password must be consist of eight or more alphanumeric characters. If no password has been specified on the command line, it prompts you to enter and reenter the wallet password.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Step 3: Generate Master encryption Key into wallet.&lt;/h4&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;SQL&amp;gt; CONN / AS SYSDBA&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY "oracle123";&lt;/i&gt;&lt;br /&gt;
These will generate a random TDE master encryption key and save it to wallet. The password you given here is the wallet password not the master encryption key.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Step 4: Open the wallet if it is closed.&lt;/h4&gt;
&lt;br /&gt;
Before you proceed to create an encrypted tablespace, the Oracle wallet containing the tablespace master encryption key must be open. The wallet must also be open before you can access data in an encrypted tablespace. Wallets must be reopened after an instance restart and can be closed to prevent access to encrypted data. Once the wallet has been opened, it remains open until you shut down the database&lt;br /&gt;
instance, or close it explicitly by issuing the close command. When you restart the instance, you must issue the OPEN command again.&lt;br /&gt;
&lt;br /&gt;
SQL&amp;gt; ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "oracle123";&lt;br /&gt;
SQL&amp;gt; ALTER SYSTEM SET ENCRYPTION WALLET CLOSE IDENTIFIED BY "oracle123";&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Step 5: Create Encrypted Tablespace&lt;/h4&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;CREATE TABLESPACE enc_tbs DATAFILE '/oradata/enc_tbs01.dbf' SIZE 200M AUTOEXTEND ON NEXT 20M ENCRYPTION USING 'AES128' DEFAULT STORAGE(ENCRYPT);&lt;/i&gt;&lt;br /&gt;
You can chose other alternative encryption algorithms that are 3DES168, AES192, AES256. The key lengths are included in the names of the algorithms themselves. If no encryption algorithm is specified, the default encryption algorithm AES128 is used.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Step 6: Data Migration&lt;/h4&gt;
&lt;br /&gt;
You cannot encrypt an existing tablespace. So if you wish to encrypt existing data, you need to move them from unencrypted tablespaces to encrypted tablespaces. For doing this you use:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Oracle Data Pump utility.&lt;/li&gt;
&lt;li&gt;Commands like CREATE TABLE...AS SELECT...&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Move tables like ALTER TABLE...MOVE.. &amp;nbsp;or rebuild indexes.&lt;/li&gt;
&lt;li&gt;Oracle Table Redefinition.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
To check whether the tablesspaces is encrypted&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; SELECT TABLESPACE_NAME,ENCRYPTED FROM DBA_TABLESPACES; &lt;/i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
TABLESPACE_NAME &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ENCRYPTED&lt;br /&gt;
------------------------------ ---------------------&lt;br /&gt;
SYSAUX &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NO&lt;br /&gt;
USER &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NO&lt;br /&gt;
ENC_TBS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; YES&lt;br /&gt;
&lt;br /&gt;
Setting and Resetting the Master Encryption Key&lt;br /&gt;
ALTER SYSTEM SET ENCRYPTION KEY ["certificate_ID"] IDENTIFIED BY "password";&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Opening and Closing the Encrypted Wallet&lt;/h4&gt;
&lt;br /&gt;
The database must load the master encryption key into memory before it can encrypt or decrypt columns/tablespaces. Opening the wallet allows the database to access the master encryption key. Use the following ALTER SYSTEM command to explicitly open the wallet:&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "password";&lt;/i&gt;&lt;br /&gt;
Once the wallet has been opened, it remains open until you shut down the database instance, or close it explicitly by issuing the following command:&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER SYSTEM SET ENCRYPTION WALLET CLOSE IDENTIFIED BY "password";&lt;/i&gt;&lt;br /&gt;
Each time you restart a database instance, you must explicitly open the wallet before open the database.&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; STARTUP MOUNT;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "password";&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER DATABASE OPEN;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;br /&gt;
&lt;h4&gt;
Backup and Recovery of Master Encryption Keys&lt;/h4&gt;
&lt;br /&gt;
You cannot access any encrypted data without the master encryption key. As the master encryption key is stored in the Oracle wallet, the wallet should be periodically backed up in a secure location. You must back up a copy of the wallet whenever a new master encryption key is set. Recovery Manager (RMAN) does not back up the wallet as part of the database backup. If you lose the wallet that stores the master encryption key, you can restore access to encrypted data by copying the backed-up version of the wallet to the appropriate location. If the restored wallet was archived after the last time that the master encryption key was reset, then no additional action needs to be taken. If the restored wallet does not contain the most recent master encryption key, then you can recover old data up to the point when the master encryption key was reset by rolling back the state of the database to that point in time. All modifications to encrypted columns after the master encryption key was reset are lost.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>TDE Part-1: Transparent Data Encryption</title><link>http://shaharear.blogspot.com/2014/04/part-1-transparent-data-encryption-tde.html</link><category>Oracle Basics</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Fri, 18 Apr 2014 21:09:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-861663297673313792</guid><description>Transparent Data Encryption (TDE), part of Oracle Advanced Security, &amp;nbsp;encrypts critical data that are stored in data files in the form of tables, indexes, materialized views etc. Oracle provides several security mechanism for authentication and authorization to validate database users who access data. All these measures are there for secure access control but not any for database files such as datafiles, redo log and archive log files. If you have the datafiles, you can see the data though you have no access in the database. Therefore file level security is required to protect the data. On other side, you want minimal configurations or changes in middle and top layer of the application to achieve database file level security.&lt;br /&gt;
&lt;br /&gt;
In 10g Release 2, Oracle first introduce TDE, a transparent data encryption-decryption mechanism to secure data stored in datafiles. Here transparent means database users or application need not to do any changes to achieve TDE. Database itself will encrypt data while writing into datafiles and decrypt then while reading. database users and applications not even bother for data encryption-decryption, Oracle database will do these transparently for them. &amp;nbsp; &amp;nbsp;To prevent unauthorized decryption, transparent data encryption stores the encryption keys in a&lt;br /&gt;
security module (oracle wallet) external to the database. Data is transparently encrypt/decrypted by the database, user does not require any action on their part.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
There are two types of TDE:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;TDE Column Encryption - data encryption-decryption for columns of a table. It&amp;nbsp;encrypts/decrypts data at the SQL layer.&amp;nbsp;This feature&amp;nbsp;introduce in Oracle 10g R2.&lt;/li&gt;
&lt;li&gt;TDE tablespace Encryption - data encryption-decryption for all objects that stored into the encrypted tablespace. It&amp;nbsp;encrypts/decrypts data during read/write operations&amp;nbsp;This feature introduced in Oracle 11g R1.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;h3&gt;
Restrictions on Using TDE Column Encryption&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Do not use TDE column encryption with the following database features:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Index types other than B-tree&lt;/li&gt;
&lt;li&gt;Range scan search through an index&lt;/li&gt;
&lt;li&gt;External large objects (BFILE)&lt;/li&gt;
&lt;li&gt;Synchronous Change Data Capture&lt;/li&gt;
&lt;li&gt;Transportable Tablespaces&lt;/li&gt;
&lt;li&gt;Original import/export utilities does not support. You need to use Oracle Data Pump.&lt;/li&gt;
&lt;li&gt;TDE encrypted columns can't be use as foreign key constraints.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;h3&gt;
Restrictions on Using TDE Tablespace Encryption&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Majority of the restrictions that apply to TDE column encryption, such as data type restrictions and index type restrictions are not applicable to TDE tablespace encryption. Though, the are some other restrictions&lt;br /&gt;
that apply to TDE tablespace encryption:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;External Large Objects (BFILEs) can not be encrypted using TDE tablespace encryption. This is because these files reside outside the database.&lt;/li&gt;
&lt;li&gt;To perform import and export operations, you need to use Oracle Data Pump.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;h3&gt;
Things You Need To Consider Before Implementing TDE&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;4-8% performance impact in end-user response time and an increase of 1-5% in CPU usage. Though it ensure below 10% performance impact.&lt;/li&gt;
&lt;li&gt;Existing tablespace can not be converted to encrypted tablespace. You need to use table reorganize/redefinition or datapump Export-Import for Migration.&lt;/li&gt;
&lt;li&gt;Increase disk consumption. Encrypting a single column would require between 32 and 48 bytes of additional storage for each row, on average. Though TDE tablespace encryption has no storage overheads.&lt;/li&gt;
&lt;li&gt;Require Goldengate 11.1.1.1 for replication&lt;/li&gt;
&lt;li&gt;Increase RMAN(backup/restore) &amp;amp; DataPump(export/import) duration.&lt;/li&gt;
&lt;li&gt;Need Separate backup task for Wallet that contains encryption decryption master key.&lt;/li&gt;
&lt;li&gt;Need Oracle Advanced Security Licence (11,500 USD/Core).&lt;/li&gt;
&lt;li&gt;Using a PKI key pair (PKI certificate) as a master encryption key may result in greater performance degradation when accessing encrypted columns in the database.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>OPTIMIZER_FEATURES_ENABLE: Downgrade Oracle optimizer functionality</title><link>http://shaharear.blogspot.com/2013/07/optimizerfeaturesenable-downgrade.html</link><category>Oracle Tips And Tricks</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Sun, 7 Jul 2013 17:06:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-2551519874997322705</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
After database up gradation or patched, you may find some under performing SQL statements. Due to one or more bug fixes Oracle optimizer my generate different execution plans for those SQL statements, &amp;nbsp;hence performance degraded . You need reasonable amount of time to tune them but unable to afford it in production environment! You have to do something quick ..........&lt;br /&gt;
&lt;br /&gt;
In such situation, you can downgrade the optimizer functionality to a previous version or patch set; so that &amp;nbsp;optimizer just act like it's previous behavior. When you finish SQL optimization/tuning, you can switch to the upgraded or patched &amp;nbsp;optimizer version.&lt;br /&gt;
&lt;br /&gt;
OPTIMIZER_FEATURES_ENABLE - An Initialization Parameter which can be altered at the system or session level to facilitate down gradation of oracle optimizer.&lt;br /&gt;
&lt;br /&gt;
Current version (after up gradation or patched): 11.2.0.3&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER SYSTEM SET optimizer_features_enable='11.2.0.2' scope=both;&lt;/i&gt;&lt;br /&gt;
or&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER SESSION SET optimizer_features_enable='11.2.0.2';&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Switch to current version&lt;br /&gt;
&lt;i&gt;SQL&amp;gt; ALTER SYSTEM SET optimizer_features_enable='11.2.0.3' scope=both;&lt;/i&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Measure Table Size in ORACLE</title><link>http://shaharear.blogspot.com/2013/07/measure-table-size-in-oracle.html</link><category>Day to Day Learning</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Thu, 4 Jul 2013 11:29:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7869295682855113218</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Sometimes it is required to measure how much space a tables occupy in Oracle. The size sum-up table and its co-related indexes, partitions, lobs, lob partitions. here are two SQL scripts, first one listed all tables own by a specific user and second one &amp;nbsp;include tablespace too.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;SELECT segment_name, sum(size_mb) size_mb&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;FROM (&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;SELECT CASE WHEN x.segment_type in ('LOBSEGMENT','LOB PARTITION') THEN&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; (SELECT table_name FROM dba_lobs y WHERE y.segment_name= x.segment_name)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; WHEN x.segment_type='LOBINDEX' THEN&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; (SELECT table_name FROM dba_lobs y WHERE y.index_name = x.segment_name)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; WHEN x.segment_type in('INDEX','INDEX PARTITION','INDEX SUBPARTITION') THEN&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; (SELECT y.table_name FROM dba_indexes y WHERE y.index_name = x.segment_name)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; WHEN x.segment_type in ('TABLE SUBPARTITION', 'TABLE PARTITION','TABLE')&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; THEN x.segment_name END segment_name&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;,round(sum(x.bytes)/(1024*1024),2) size_mb&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;FROM dba_segments x&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;WHERE x.owner ='SCOTT'&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;GROUP BY x.segment_name, x.segment_type&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;GROUP BY segment_name&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;ORDER BY size_mb DESC;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;SELECT segment_name, tablespace_name, sum(size_mb) size_mb&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;FROM (&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;SELECT CASE WHEN x.segment_type in ('LOBSEGMENT','LOB PARTITION') THEN&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; (SELECT table_name FROM dba_lobs y WHERE y.segment_name= x.segment_name)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; WHEN x.segment_type='LOBINDEX' THEN&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; (SELECT table_name FROM dba_lobs y WHERE y.index_name = x.segment_name)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; WHEN x.segment_type in('INDEX','INDEX PARTITION','INDEX SUBPARTITION') THEN&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; (SELECT y.table_name FROM dba_indexes y WHERE y.index_name = x.segment_name)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; WHEN x.segment_type in ('TABLE SUBPARTITION', 'TABLE PARTITION','TABLE')&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;&amp;nbsp; THEN x.segment_name END segment_name&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;, x.tablespace_name&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;, round(sum(x.bytes)/(1024*1024),2) size_mb&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;FROM dba_segments x&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;WHERE x.owner ='SCOTT'&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;GROUP BY x.segment_name, x.tablespace_name,x.segment_type&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;GROUP BY segment_name, tablespace_name&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;i&gt;ORDER BY size_mb DESC;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></item><item><title>Recover Database from ORA-00333: redo log read error</title><link>http://shaharear.blogspot.com/2013/06/recover-database-from-ora-00333-redo.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Thu, 27 Jun 2013 18:56:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-2568859003843372107</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;In development environment, it is very common scenario that we have multiple databases in a single machine by using VMware (i.e, each VMware contains one database). Again those machines doesn't have consistant power backup. Therefore we have to face power failure or VMware hang-up. So, we are forced to restart the machine while databases are still up &amp;amp; running. After restarting the machine, we have mostly got he following error:&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;&amp;nbsp;ORA-00333: redo log read error block &lt;number&gt; count &lt;number&gt;.&lt;/number&gt;&lt;/number&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Here are the steps to overcome the error&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;SQL&amp;gt; startup
ORACLE instance started.
Total System Global Area ***** bytes
Fixed Size               ***** bytes
Variable Size            ***** bytes
Database Buffers         ***** bytes
Redo Buffers             ***** bytes
Database mounted.
 
 ORA-00333: redo log read error block *Number* count *Number*&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;b&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;Step 1:&lt;/b&gt;&amp;nbsp;As the Db is in mount mode, We can query v$log &amp;amp; v$logfile to identify &lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;the status of log file group and their member.&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt; &lt;i&gt;SQL&amp;gt; select l.status, member from v$logfile inner join v$log l using (group#);&lt;/i&gt;&lt;/span&gt;&lt;i style="font-family: Arial, Helvetica, sans-serif;"&gt; &lt;/i&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;i&gt; STATUS  MEMBER
 ------------- --------------------------------------
 CURRENT /oracle/fast_recovery_area/redo01.log
 INACTIVE /oracle/fast_recovery_area/redo02.log
 INACTIVE /oracle/fast_recovery_area/redo03.log&lt;/i&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;b&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;Step 2:&lt;/b&gt; Recover the database using ackup controlfile.&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt; &lt;i&gt;SQL&amp;gt; recover database using backup controlfile;&lt;/i&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;i&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;ORA-00279: change &lt;number&gt; generated at &lt;timestamp&gt; needed for thread 1
ORA-00289: suggestion : /oracle/fast_recovery_area/archivelog/o1_mf_1_634_%u_.arc
ORA-00280: change &lt;number&gt; for thread 1 is in sequence #&lt;number&gt;
Specify log: {&lt;ret&gt;=suggested | filename | AUTO | CANCEL}&lt;/ret&gt;&lt;/number&gt;&lt;/number&gt;&lt;/timestamp&gt;&lt;/number&gt;&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;i&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;Step3:&lt;/b&gt; Give 'CURRENT' log file member along with location as input. If it does not &lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;work give other log file members along with location in input prompt. In our case&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;we give&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;i&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;/oracle/fast_recovery_area/redo01.log&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;i&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Log applied.
Media recovery complete.&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;Step 4:&lt;/b&gt; Open the database with reset logfile&lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;i&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;SQL&amp;gt; alter database open resetlogs;&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;i&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Database altered.&lt;/span&gt;&lt;/i&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Manage SYS.AUD$ table</title><link>http://shaharear.blogspot.com/2013/06/manage-sysaud-table.html</link><category>Administration and Maintenance</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 19 Jun 2013 15:40:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-8084892665696025759</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div&gt;
From 11g, Oracle by default enable auditing with 'DB' option. &amp;nbsp;That means audit information will store in database table. With this settings Oracle will audit following activities:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;ALTER ANY PROCEDURE, ALTER ANY TABLE,&amp;nbsp;ALTER DATABASE,ALTER PROFILE, ALTER SYSTEM,&amp;nbsp;ALTER USER, AUDIT SYSTEM, CREATE ANY JOB,&amp;nbsp;CREATE ANY LIBRARY, CREATE ANY PROCEDURE,&amp;nbsp;CREATE ANY TABLE, CREATE EXTERNAL JOB,&amp;nbsp;CREATE PUBLIC DATABASE LINK, CREATE SESSION,&amp;nbsp;CREATE USER, DATABASE LINK, DROP ANY PROCEDURE,&amp;nbsp;DROP ANY TABLE, DROP PROFILE&lt;br /&gt;DROP USER, EXEMPT ACCESS POLICY, GRANT ANY OBJECT PRIVILEGE, GRANT ANY PRIVILEGE,&amp;nbsp;GRANT ANY ROLE, PROFILE, PUBLIC SYNONYM&amp;nbsp;ROLE, SYSTEM AUDIT&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Apart from lot of benefits,&amp;nbsp; auditing may raise 
performance issues and the reasons are:&lt;/div&gt;
&lt;div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Too much activity is being audited&lt;/li&gt;
&lt;li&gt;AUD$ table still placed in the SYSTEM 
tablespace&lt;/li&gt;
&lt;li&gt;Oracle bugs.&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;1. Too much is being audited&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The more activity you audit the more audit records will generate. &amp;nbsp;You need to restrict unnecessary auditing because it cost your resources and hamper performance. To see which activities are being audited&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div style="text-align: left;"&gt;
&lt;i&gt;SELECT &amp;nbsp;* FROM DBA_PRIV_AUDIT_OPTS&amp;nbsp;&lt;span style="font-family: monospace;"&gt;UNION&amp;nbsp;&lt;/span&gt;SELECT * FROM DBA_STMT_AUDIT_OPTS;&lt;/i&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. AUD$ table still placed in SYSTEM 
tablespace:&lt;/b&gt;&lt;/div&gt;
By default AUD$ table lies in SYSTEM tablespace. &amp;nbsp;You will face space managment issue if you not move AUD$ table in SYSAUX tablespace
 along with indexes. &amp;nbsp;Use Oracle recommended 
package DBMS_AUDIT &amp;nbsp;to purge old unnecessary entries. Periodically shrink / truncate AUD$ table.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;BEGIN&lt;br /&gt;
&lt;div class="container"&gt;
&lt;div class="line number2 index1 alt1"&gt;
&lt;code class="xml spaces"&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="xml plain"&gt;DBMS_AUDIT_MGMT.set_audit_trail_location(&lt;/code&gt;&lt;/div&gt;
&lt;div class="line number3 index2 alt2"&gt;
&lt;code class="xml spaces"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="xml plain"&gt;audit_trail_type =&amp;gt; DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD,&lt;/code&gt;&lt;/div&gt;
&lt;div class="line number4 index3 alt1"&gt;
&lt;code class="xml spaces"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="xml plain"&gt;audit_trail_location_value =&amp;gt; 'SYSAUX');&lt;/code&gt;&lt;/div&gt;
&lt;div class="line number5 index4 alt2"&gt;
&lt;code class="xml plain"&gt;END;&lt;/code&gt;&lt;/div&gt;
&lt;div class="line number6 index5 alt1"&gt;
&lt;code class="xml plain"&gt;/&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre&gt;BEGIN
  DBMS_AUDIT_MGMT.clean_audit_trail(
   audit_trail_type =&amp;gt; DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
   use_last_arch_timestamp =&amp;gt; TRUE);
END;
/&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;CREATE TABLE AUD_BACKUP AS SELECT * FROM AUD$;&lt;/pre&gt;
&lt;pre&gt;TRUNCATE AUD$;&lt;/pre&gt;
&lt;pre&gt;INSERT INTO AUD$ SELECT * FROM AUD_BACKUP;&lt;/pre&gt;
&lt;pre&gt;DROP TABLE AUD_BACKUP PURGE;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;/pre&gt;
&lt;b&gt;3. Oracle bugs&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Well there are couple of&amp;nbsp; known bugs, so apply latest patch.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Resources:&lt;/div&gt;
&lt;div&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="http://juliandontcheff.wordpress.com/2011/05/12/auditing-vs-performance-in-the-oracle-database" target="_blank"&gt;http://juliandontcheff.&lt;wbr&gt;&lt;/wbr&gt;wordpress.com/2011/05/12/&lt;wbr&gt;&lt;/wbr&gt;auditing-vs-performance-in-&lt;wbr&gt;&lt;/wbr&gt;the-oracle-database&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Oracle support - [ID 1375419.1, 1080112.1, 1375419.1]&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.oracle-base.com/articles/11g/auditing-enhancements-11gr2.php#purging_audit_trail_records"&gt;http://www.oracle-base.com/articles/11g/auditing-enhancements-11gr2.php#purging_audit_trail_records&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Alert: ASH performed an emergency flush</title><link>http://shaharear.blogspot.com/2013/05/alert-ash-performed-emergency-flush.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 29 May 2013 16:52:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-893444666015780759</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: left;"&gt;
&lt;u&gt;&lt;b&gt;Alert&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Active Session History (ASH) performed an emergency flush. This may 
mean that ASH is undersized. If emergency flushes are a recurring issue,
 you may consider increasing ASH size by setting the value of _ASH_SIZE 
to a sufficiently large value. Currently, ASH size is 123...7 bytes.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;u&gt;&lt;b&gt;Cause&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
This alert indicate sudden increase of database active sessions, &amp;nbsp;that fill-up ASH&amp;nbsp;buffer faster then usual and therefore raise this alert. Actually this is not a&amp;nbsp;problem but an indication of more &amp;nbsp;ASH buffer is needed to &amp;nbsp;support peak&amp;nbsp;activity on DB.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;u&gt;&lt;b&gt;Solution&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;
&amp;nbsp;_ASH_SIZE is a hidden parameter and oracle not suggested to set such parameter without&amp;nbsp;consulting their support. There is a meta link doc ( id 1385872.1)&amp;nbsp;suggest we can increase 50% of current &amp;nbsp;ASH buffer, if we repeatedly receive this alert. &amp;nbsp; To monitor use this&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;i&gt;SELECT total_size,awr_flush_&lt;wbr&gt;&lt;/wbr&gt;emergency_count FROM v$ash_info;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Oracle Wallet: secure external password storage</title><link>http://shaharear.blogspot.com/2013/05/oracle-wallet-secure-external-password.html</link><category>Oracle Administration and Maintenance</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Mon, 13 May 2013 16:49:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1560441801837633455</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
Some times we need database connection from shell script stored on file system. This can be a security issue, if the script contains database connection credential. To nullify this problem oracle provide a solution called wallet. Oracle wallet is a client-side secure external password container where DB login credentials are stored. Using this shell scripts can connect to DB using the "/@db_alias" syntax.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 1 : Set location for wallet&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
we Like to put the wallet files in $ORACLE_HOME/network/admin. Thus the location will be '/oracle/product/11.2.0/dbhome_1/network/admin'. Add following lines to sqlnet.ora&lt;br /&gt;
&lt;br /&gt;
WALLET_LOCATION = (SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/oracle/product/11.2.0/dbhome_1/network/admin)))&lt;br /&gt;
SQLNET.WALLET_OVERRIDE = TRUE&lt;br /&gt;
SSL_CLIENT_AUTHENTICATION = FALSE&lt;br /&gt;
SSL_VERSION = 0&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Step 2: Set DB alias&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Add the following lines to listerer.ora&lt;br /&gt;
&lt;br /&gt;
ora_db =&lt;br /&gt;
&amp;nbsp; (DESCRIPTION =&lt;br /&gt;
&amp;nbsp; &amp;nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; (CONNECT_DATA =&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; (SERVER = DEDICATED)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; (SERVICE_NAME = ORA.DB1.ORACLE.COM) ) )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 3: Create Wallet&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;mkstore -wrl '/oracle/product/11.2.0/dbhome_1/network/admin' -create&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
You will ask to enter password. The password length must be 8+ containing alpha-numeric characters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 4: Add database login credentials into wallet&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;mkstore -wrl '/oracle/product/11.2.0/dbhome_1/network/admin' -createCredential ora_db scott tiger&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This will ask for password conformation and you shout give the same password which you gave when creating wallet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 5: Listing credentials present in wallet&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;mkstore -wrl '/oracle/product/11.2.0/dbhome_1/network/admin' -listCredential&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Step 6: Connect Db using wallet&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;sqlplus /@ora_db&lt;/i&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Oracle Recovery Manager (RMAN) Overview</title><link>http://shaharear.blogspot.com/2013/05/oracle-recovery-manager-rman-overview.html</link><category>Recovery Manager (RMAN)</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 1 May 2013 19:10:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-6996743612867530926</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In general, backup &amp;amp; recovery combines several strategies &amp;amp; procedures which are protecting database against data lose and reconstructing the database after any kind of data loss. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two types of backup strategies: &lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Physical Backup – are backups of the physical files used in restoring &amp;amp;recovering database, such as datafiles, controlfiles and archived redo logs.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Logical Backup – contains logical data exported from database with oracle utilities (i.e, datapump) and stored in a binary file. &lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Physical backup is the foundation of any sound backup &amp;amp; recovery strategy. Logical backup is a useful supplement to physical backup but not ensure sufficient protection against data loss without physical backup. Unless otherwise specified, the term backup refers to physical backup. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Oracle provides two backup &amp;amp; recovery solutions –&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Recovery Manager (RMAN) managed backup &amp;amp; recovery. &lt;/li&gt;
&lt;li&gt;User managed backup &amp;amp; recovery. &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
RMAN can take backups of –&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Datafiles&lt;/li&gt;
&lt;li&gt;Controlfiles&lt;/li&gt;
&lt;li&gt;Redo logs / archived redo logs&lt;/li&gt;
&lt;li&gt;Serve parameter file (SPFiles) &lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
A database recovery involved two tasks:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Restore- retrieve datafiles or controlfiles from backup.&lt;/li&gt;
&lt;li&gt;Recover- apply archived &amp;amp; on-line redo log changes on restored datafiles ( it is also known as media recovery) &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>DBMS_XMLGEN: SAve SQL query result in XML </title><link>http://shaharear.blogspot.com/2013/03/dbmsxmlgen-save-sql-query-result-in-xml.html</link><category>Export-Import</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Mon, 25 Mar 2013 15:30:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-8243110735553186978</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;DBMS_XMLGEN&lt;/b&gt; is a useful Oracle package that gives you a query result in XML file. Couple of days ago I have got a task to export all tables of an schema in different XML files. Here&amp;nbsp; is the PL/SQL code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;grant read,write on directory DUMP_DIR to scott;&lt;br /&gt;grant execute on DBMS_XMLGEN to scott;&lt;br /&gt;grant execute on utl_file to scott;&lt;br /&gt;&lt;br /&gt;set serveroutput on;&lt;br /&gt;set echo on;&lt;br /&gt;set timing on;&lt;br /&gt;spool export_schema_xml.log;&lt;br /&gt;DECLARE&lt;br /&gt;&amp;nbsp; qryCtx DBMS_XMLGEN.ctxHandle;&lt;br /&gt;&amp;nbsp; l_output utl_file.file_type;&lt;br /&gt;&amp;nbsp; l_amount NUMBER default 4000;&lt;br /&gt;&amp;nbsp; l_offset NUMBER(38) default 1;&lt;br /&gt;&amp;nbsp; l_length NUMBER(38);&lt;br /&gt;&amp;nbsp; sqltext VARCHAR2 (4000 CHAR);&lt;br /&gt;&amp;nbsp; result CLOB;&lt;br /&gt;&amp;nbsp; l_buffer VARCHAR2 (4000 CHAR);&lt;br /&gt;BEGIN&lt;br /&gt;FOR x IN (SELECT x.table_name FROM user_tables x)&lt;br /&gt;LOOP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp; l_offset :=1;&lt;br /&gt;&amp;nbsp; sqltext := 'SELECT * FROM '||x.table_name;&lt;br /&gt;&amp;nbsp; qryCtx :=&amp;nbsp; dbms_xmlgen.newContext (sqltext);&lt;br /&gt;&amp;nbsp; DBMS_XMLGEN.SETCONVERTSPECIALCHARS (qryCtx,FALSE);&lt;br /&gt;&amp;nbsp; result :=&amp;nbsp; DBMS_XMLGEN.getXML(qryCtx);&lt;br /&gt;&amp;nbsp; l_output := utl_file.fopen('DUMP_DIR', x.table_name||'.xml', 'w', 32760);&lt;br /&gt;&amp;nbsp; l_length:=nvl(dbms_lob.getlength(result),0);&lt;br /&gt;&amp;nbsp; WHILE ( l_offset &amp;lt; l_length AND l_length &amp;gt; 0 )&lt;br /&gt;&amp;nbsp; LOOP&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS_LOB.READ (result, l_amount, l_offset, l_buffer);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; utl_file.put (l_output, l_buffer);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; utl_file.fflush(l_output);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; utl_file.fflush(l_output);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l_offset := l_offset + l_amount;&lt;br /&gt;&amp;nbsp; END LOOP;&lt;br /&gt;&amp;nbsp; utl_file.fflush(l_output);&lt;br /&gt;&amp;nbsp; utl_file.fclose(l_output);&lt;br /&gt;&amp;nbsp; DBMS_XMLGEN.CLOSECONTEXT (qryCtx);&lt;br /&gt;&amp;nbsp; dbms_output.put_line(x.table_name||' Data Exported');&lt;br /&gt;END LOOP;&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;br /&gt;spool off;&lt;/i&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>ORA-03113: end-of-file on communication channel</title><link>http://shaharear.blogspot.com/2013/03/ora-03113-end-of-file-on-communication.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Sat, 16 Mar 2013 20:49:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-6306142560054282060</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;ERROR &lt;/b&gt;&lt;br /&gt;
ORA-03113: end-of-file on communication channel&lt;br /&gt;
Process ID: 28105&lt;br /&gt;
Session ID: 130 Serial number: 5&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Cause:&lt;/b&gt; This error may pop-up when you trying to start-up a database after executing 'shutdown abort' or unexpected shutdown of db due to powe failure. This error occurs when oracle fail to archive online redo log file.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Action:&lt;/b&gt; if your db is in archivelog mode then bring the db in noarchivelog mode and startup the db. Then, execute a normal shutdown and bring back the db in archivelog mode.&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;SQL&amp;gt; startup mount;&lt;br /&gt;SQL&amp;gt; alter database noarchivelog;&lt;br /&gt;SQL&amp;gt; alter database open;&lt;br /&gt;SQL&amp;gt; shutdown immediate;&lt;br /&gt;SQL&amp;gt; startup mount;&lt;br /&gt;SQL&amp;gt; alter database archivelog;&lt;br /&gt;SQL&amp;gt; alter database open;&lt;/i&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Finding Duplicate SQL</title><link>http://shaharear.blogspot.com/2013/03/finding-duplicate-sql.html</link><category>Day to Day Learning</category><category>Oracle Tips And Tricks</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 13 Mar 2013 12:36:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7085496075454667915</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
The presence of duplicate SQL indicate that there are some SQL statements which doesn't have Bind variables. These duplicate SQL can raise performance issue because they will increase the number of hard parse in database.&lt;br /&gt;
&lt;br /&gt;
ORACLE 10g introduced two new columns in &lt;b&gt;v$sql&lt;/b&gt; view, which can help to identifing duplicate SQL more accurately. Those two new columns are:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;force_matching_signature&amp;nbsp;&lt;/li&gt;
&lt;li&gt;exact_matching_signature&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;&lt;b&gt;exact_matching_signature&lt;/b&gt; - If two or more SQL has same value in this column, ORACLE assumes they are same after making some cosmetic adjustments (removing white space, uppercasing all keywords etc) to them. The is simmiler, when parameter cursor_sharing is set to EXACT.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;force_matching_signature&lt;/b&gt; - the same value in this column (excluding 0) marks SQLs that ORACLE will consider they are same when it replaces all literals with binds (that is, if cursor_sharing=FORCE).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT sql_text , count(1)&lt;br /&gt;FROM v$sql&lt;br /&gt;WHERE force_matching_signature &amp;gt; 0&lt;br /&gt;&amp;nbsp; AND force_matching_signature &amp;lt;&amp;gt; exact_matching_signature&lt;br /&gt;GROUP BY sql_text&lt;br /&gt;HAVING count(1) &amp;gt; 10&lt;br /&gt;ORDER BY 2;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Transportable Tablespace (TTS)</title><link>http://shaharear.blogspot.com/2012/04/transportable-tablespace-tts.html</link><category>ERROR: ORA-</category><category>Oracle Administration and Maintenance</category><category>Oracle Tips And Tricks</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Fri, 27 Apr 2012 13:43:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1512296828575796272</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;br /&gt;
'Transportable Tablespace' (TTS) first introduce in Oracle 8i and it become matured as time goes by.&amp;nbsp; You can use this&amp;nbsp; feature to copy a set of tablespaces from one Oracle Database to another.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For a DBA, transport data from one database to another is a very common task and you can do it in different ways&lt;br /&gt;
&lt;br /&gt;
Method &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hardness &amp;nbsp;&amp;nbsp;&amp;nbsp; Best Suitable For&amp;nbsp;&amp;nbsp;&amp;nbsp; Availability&lt;br /&gt;
&lt;br /&gt;
Database Link &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Easy &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Less than 50 GB &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; High&lt;br /&gt;
Data Pump &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Moderate &amp;nbsp;&amp;nbsp;&amp;nbsp; Over 50 GB &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; High&lt;br /&gt;
TTS &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Moderate &amp;nbsp;&amp;nbsp;&amp;nbsp; Terabytes of Data&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Low&lt;br /&gt;
RMAN Duplicate&amp;nbsp;&amp;nbsp;&amp;nbsp; Hard &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Full Database &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; High&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Requirements:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;A tablespace must be totally self contained to be transportable.&lt;/li&gt;
&lt;li&gt;The source and target database must use the same character set and national character set.&lt;/li&gt;
&lt;li&gt;You cannot transport a tablespace to a target database in which a tablespace with the same name already exists.&lt;/li&gt;
&lt;li&gt;Objects with underlying objects (such as materialized views) or contained objects (such as partitioned tables) are not transportable unless all of the underlying or contained objects are in the tablespace set.&lt;/li&gt;
&lt;li&gt;There are some limitations in encryption tables. &lt;/li&gt;
&lt;/ul&gt;
Lets see how it works.................&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;b&gt;&lt;u&gt;IN SOURCE DATABASE&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;1. Create two tablespaces and one user&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
sqlplus / as sysdba; &lt;br /&gt;
&lt;br /&gt;
CREATE TABLESPACE TT01 DATAFILE '/oradata/tt_01.dbf' SIZE 50M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED BLOCKSIZE 8K EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M SEGMENT SPACE MANAGEMENT AUTO ONLINE ;&lt;br /&gt;
&lt;br /&gt;
CREATE TABLESPACE TT02 DATAFILE '/oradata/tt_02.dbf' SIZE 50M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED BLOCKSIZE 16K EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M SEGMENT SPACE MANAGEMENT AUTO ONLINE ;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CREATE USER test identified by test default tablespace tt01;&lt;br /&gt;
GRANT connect,resource to test;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;2. Create a table with some data&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
conn test/test;&lt;br /&gt;
&lt;br /&gt;
CREATE TABLE test_data(&lt;br /&gt;
id number (10),&lt;br /&gt;
alphabate varchar2 (10)&lt;br /&gt;
) TABLESPACE tt01;&lt;br /&gt;
&lt;br /&gt;
ALTER TABLE test_data ADD CONSTRAINT PK_TEST_DATA_ID PRIMARY KEY (ID) using index tablespace tt02; &lt;br /&gt;
&lt;br /&gt;
INSERT INTO test_data VALUES (1,'A');&lt;br /&gt;
INSERT INTO test_data VALUES (2,'B');&lt;br /&gt;
INSERT INTO test_data VALUES (3,'C');&lt;br /&gt;
INSERT INTO test_data VALUES (4,'D');&lt;br /&gt;
INSERT INTO test_data VALUES (5,'E');&lt;br /&gt;
&lt;br /&gt;
commit;&lt;br /&gt;
&lt;br /&gt;
SELECT segment_name, tablespace_name from user_segments;&lt;br /&gt;
&lt;br /&gt;
SEGMENT_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLESPACE_NAME&lt;br /&gt;
------------------ ------------------&lt;br /&gt;
TEST_DATA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TT01&lt;br /&gt;
PK_TEST_DATA_ID&amp;nbsp;&amp;nbsp;&amp;nbsp; TT02&lt;br /&gt;
&lt;br /&gt;
So we have a table in one tablespace and an unique index (creat for primary key) in another tablespace. &lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;3. tablespace's 'self contained' Test&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
conn / as sysdba;&lt;br /&gt;
&lt;br /&gt;
EXEC DBMS_TTS.TRANSPORT_SET_CHECK(ts_list =&amp;gt; 'TT01', incl_constraints =&amp;gt; TRUE);&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM sys.transport_set_violations;&lt;br /&gt;
&lt;br /&gt;
VIOLATIONS&lt;br /&gt;
------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;
ORA-39908: Index TEST.PK_TEST_DATA_ID in tablespace TT02 enforces primary constraints&amp;nbsp; of table TEST.TEST_DATA in tablespace TT01.&lt;br /&gt;
&lt;br /&gt;
we got this error because TT01 tablespace contain a table which has an index stored in another tablespace.&lt;br /&gt;
&lt;br /&gt;
EXEC DBMS_TTS.TRANSPORT_SET_CHECK(ts_list =&amp;gt; 'TT01,TT02', incl_constraints =&amp;gt; TRUE);&lt;br /&gt;
&lt;br /&gt;
SQL&amp;gt; SELECT * FROM sys.transport_set_violations;&lt;br /&gt;
&lt;br /&gt;
no rows selected&lt;br /&gt;
&lt;br /&gt;
This time no Error because all two tablespaces are included. Now make them 'Read Only'. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ALTER TABLESPACE tt01 READ ONLY;&lt;br /&gt;
ALTER TABLESPACE tt02 READ ONLY;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;4. Take metadata of those 2 tablespaces by using datapump&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
expdp system directory=dump_dir transport_tablespaces=tt01,tt02 dumpfile=trans_tablespaces.dmp logfile=trans_tablespaces.log&lt;br /&gt;
&lt;br /&gt;
Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01":&amp;nbsp; system/ ******** directory=dump_dir transport_tablespaces=tt01,tt02 dumpfile=trans_tablespaces.dmp logfile=trans_tablespaces.log &lt;br /&gt;
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK&lt;br /&gt;
Processing object type TRANSPORTABLE_EXPORT/TABLE&lt;br /&gt;
Processing object type TRANSPORTABLE_EXPORT/INDEX&lt;br /&gt;
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT&lt;br /&gt;
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS&lt;br /&gt;
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK&lt;br /&gt;
Master table "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded&lt;br /&gt;
******************************************************************************&lt;br /&gt;
Dump file set for SYSTEM.SYS_EXPORT_TRANSPORTABLE_01 is:&lt;br /&gt;
&amp;nbsp; /d01/dump_dir/trans_tablespaces.dmp&lt;br /&gt;
******************************************************************************&lt;br /&gt;
Datafiles required for transportable tablespace TT01:&lt;br /&gt;
&amp;nbsp; /oradata/tt_01.dbf&lt;br /&gt;
Datafiles required for transportable tablespace TT02:&lt;br /&gt;
&amp;nbsp; /oradata/tt_02.dbf&lt;br /&gt;
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 02:27:17&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;5. Copy the datafiles to destination database&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
scp tt_01.dbf oracle@db2:/oradata/&lt;br /&gt;
scp tt_02.dbf oracle@db2:/oradata/&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;6. Make the read_only tablespaces to read write mode&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
sqlplus / as sysdba&lt;br /&gt;
&lt;br /&gt;
ALTER TABLESPACE tt01 READ WRITE;&lt;br /&gt;
ALTER TABLESPACE tt02 READ WRITE;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;IN DESTINATION DB &lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;1. Create a user same as source DB&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
sqlplus / as sysdba;&lt;br /&gt;
&lt;br /&gt;
CREATE USER test identified by test ;&lt;br /&gt;
GRANT connect,resource to test;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;2. Import the metadata &lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
impdp system directory=dump_dir dumpfile=trans_tablespaces.dmp transport_datafiles='/oradata/tt_01.dbf','/oradata/tt_02.dbf' logfile=imp_trans_tablespaces.log&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;3. Verify Tablespace and Object Movement&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
conn test/test&lt;br /&gt;
&lt;br /&gt;
SELECT segment_name, tablespace_name from user_segments;&lt;br /&gt;
&lt;br /&gt;
SEGMENT_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLESPACE_NAME&lt;br /&gt;
-------------------- --------------------&lt;br /&gt;
TEST_DATA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TT01&lt;br /&gt;
PK_TEST_DATA_ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TT02&lt;br /&gt;
&lt;br /&gt;
SELECT * FROM TEST_DATA;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID ALPHABATE&lt;br /&gt;
---------- ----------&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 B&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 C&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 D&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 E&lt;br /&gt;
&lt;br /&gt;
Well we are done! To know more about TTS please go through the Oracle Doc &lt;a href="http://docs.oracle.com/cd/B28359_01/server.111/b28310/tspaces013.htm"&gt;http://docs.oracle.com/cd/B28359_01/server.111/b28310/tspaces013.htm&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>CTAS : Create Table as</title><link>http://shaharear.blogspot.com/2012/01/ctas-create-table-as.html</link><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Fri, 13 Jan 2012 08:15:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-2963435682786477245</guid><description>We all are very familiar with CTAS or 'Create Table as' clause that used to construct new table and populated it with data extract by 'Select' statement. That means table creation and population are done by executing a single sql CTAS statement.&lt;br /&gt;&lt;br /&gt;Fom example,&lt;br /&gt;&lt;br /&gt;CREATE TABLE employee_info As&lt;br /&gt;SELECT  emp.id, emp.name, dp.name FROM employee emp, department dp WHERE emp.dp_id =dp.id;&lt;br /&gt;&lt;br /&gt;The above CTAS statment create a new table named 'employee_info' and store the result of SELECT statement into that table.&lt;br /&gt;&lt;br /&gt;Here are some common use of CTAS statement:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Store the result of select statement into a table.&lt;/li&gt;&lt;li&gt;create a duplicate table for backup purpose.&lt;/li&gt;&lt;li&gt;Reorganize existing table for better performance.&lt;/li&gt;&lt;/ul&gt;There are some limitations of CTAS statement:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Can't create indexes ( in case of table duplication or Reorganization).&lt;/li&gt;&lt;li&gt;Can't create primary, unique or foreign key constraints ( in case of table duplication or Reorganization). But it can create 'NOT NULL' constraint.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Though CTAS mirrors metadata structure, it can't mirror 'DEFAULT' value checker for columns.&lt;/li&gt;&lt;/ul&gt;I have learned the 3rd pitfall of CTAS recently. I used CTAS to construct a duplicate table ( a sub task of table partitioning). The partitioning job was successful but the problem arose when we inserted new rows into the partitioned table. One of the column got null value stored instead of zero (the column's default value was zero). Through an investigation we discover that CATS statement skipped default value check of that column.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>SPM - SQL PLAN MANAGER</title><link>http://shaharear.blogspot.com/2011/12/spm-sql-plan-manager.html</link><category>Oracle Tuning</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 28 Dec 2011 17:50:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7360520121791953346</guid><description>As a &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBA&lt;/span&gt; some I feel that Oracle is living thing ! for example query performance. Out of no where a gentle looking &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement may pop up your top time consuming query list. A &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;sql&lt;/span&gt; query which gives efficient performance in 3 months ago (Or even  week ago), now giving horrible performance that threatening you cool database performance :)&lt;br /&gt;&lt;br /&gt;Yes, we all &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBA&lt;/span&gt; know that a gentle statement can screwed up due to&lt;br /&gt;- Re-&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;guthering&lt;/span&gt; optimizer statistics&lt;br /&gt;- Change in optimizes parameters&lt;br /&gt;- Change in Schema? Object structure (i.e, &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;metadata&lt;/span&gt; definition)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Though Optimizer always try to choose list expensive plan for each &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement execution, Some time It (optimizer) choose expensive plans and raise annoying situations for peace loving &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBAs&lt;/span&gt; :)&lt;br /&gt;&lt;br /&gt;Well Oracle 11g come up with a new feature that can handle such weird situation. The simplest solution we can think is a mechanism that only allow trusted &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; plans to be executed and reject untrusted plans. O Yes Oracle 11g gives us a manager named &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SPM&lt;/span&gt; that do the same thing.&lt;br /&gt;&lt;br /&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; PLAN MANAGER (&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SPM&lt;/span&gt;) has three major components&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline Capture - Create  &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline for trusted (accepted) &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; plans.&lt;/li&gt;&lt;li&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline Selection - Conform that only accepted &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQl&lt;/span&gt; plans are used when an &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement is executed.&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plan Baseline Evolution - Evaluated all &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; Plans (old &amp;amp; new) for each &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt; statement. The new/old plan will only be excepted if it gives better or equal performance compared with existing trusted plan otherwise rejected. (If no trusted plan exist then current plan will be accepted)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;To enable this cool feature we just do the followings&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ALTER SYSTEM set optimizer_capture_&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;sql&lt;/span&gt;&lt;span style="font-style: italic;"&gt;_plan_baselines= TRUE scope=both;&lt;/span&gt; [Default value is false]&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ALTER SYSTEM set optimizer_user_&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; font-style: italic;" class="J-JK9eJ-PJVNOc"&gt;sql&lt;/span&gt;&lt;span style="font-style: italic;"&gt;_plan_baselines= TRUE scope=both; &lt;/span&gt;[Default value is true, so just check the parameter value]&lt;br /&gt;&lt;br /&gt;You are done ! Keep an eye in &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;DBA&lt;/span&gt;_&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SQL&lt;/span&gt;_PLAN_BASELINES view and enjoying &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" class="J-JK9eJ-PJVNOc"&gt;SPM's&lt;/span&gt; magic&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>TABLE_EXISTS_ACTION</title><link>http://shaharear.blogspot.com/2011/12/tableexistsaction.html</link><category>Export-Import</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Tue, 27 Dec 2011 15:33:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-5354736727644668921</guid><description>Those who are familiar with oracle data pump may know very well about TABLE_EXISTS_ACTION import (impdp) parameter.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;TABLE_EXISTS_ACTION = {SKIP | APPEND | TRUNCATE | REPLACE}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This parameter is used when you import a table which is already exists in import schema. The default value is '&lt;span style="font-weight: bold;"&gt;SKIP&lt;/span&gt;', so if you not use this parameter and &lt;span style="font-style: italic;"&gt;impdp&lt;/span&gt; found that the table which to be imported is already exist then &lt;span style="font-style: italic;"&gt;impdp &lt;/span&gt;skip this table from import list.&lt;br /&gt;&lt;br /&gt;Now you may interested about rest of the three values-&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;APPEND &lt;/span&gt;- The import will be done if the   table does not have any Primary key or Unique key constraints.  If such constraint exists then you need to ensure that append operation does not violate Primary key or Unique key constraints (that means it does not occur data duplication).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;TRUNCATE&lt;/span&gt; - If the table is not a parent table ( i.e, No other table references it by creating foreign key constraint) then it truncate the existing data and load data from dump file. Otherwise data will not be loaded.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;REPLACE&lt;/span&gt; - This is the most tricky value of TABLE_EXISTS_ACTION parameter. If the importing table is a parent table ( i.e, other table references it by creating foreign key constraint ) then the foreign key will be deleted from child table.  All existing data will be replaced with imported data.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>ORA-08102</title><link>http://shaharear.blogspot.com/2011/10/ora-08102.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 19 Oct 2011 16:59:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1436207338000763634</guid><description>&lt;span style="font-weight: bold;"&gt;ORA-08102&lt;/span&gt;: index key not found, obj# 290, file 1, block 4353&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Cause:&lt;/b&gt;   Internal error: possible inconsistency in index.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Action:&lt;/b&gt;   Send trace file to your customer support representative, along with information on reproducing the error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Well I do not have access to oracle support (if you need it, you need to buy that service). So first of all, I tried to identify which index cause that problem.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;SQL&amp;gt;select OWNER,OBJECT_NAME,OBJECT_ID, OBJECT_TYPE from dba_objects x where x.object_id=290; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;OWNER &amp;nbsp; &amp;nbsp; &amp;nbsp; OBJECT_NAME &amp;nbsp; &amp;nbsp; &amp;nbsp;OBJECT_ID &amp;nbsp; OBJECT_TYPE&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;-------- ------------------- ---------- ------------&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;SYS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I_JOB_NEXT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;290 &amp;nbsp; &amp;nbsp;INDEX&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Guess what ? it's an index own by 'SYS' user. So I issued index rebuild command and it didn't work. As the index lies in system tablespace, I didn't want to move it to other tablespace. Thus I droped and created the index again. So first gather the index DDL from database&lt;br /&gt;
&lt;br /&gt;
SQL&amp;gt; set long 1000&lt;br /&gt;
SQL&amp;gt; set pagesize 0&lt;br /&gt;
SQL&amp;gt; select DBMS_METADATA.GET_DDL('INDEX','I_JOB_NEXT') from DUAL;&lt;br /&gt;
output:&lt;br /&gt;
CREATE INDEX "SYS"."I_JOB_NEXT" ON "SYS"."JOB$" ("NEXT_DATE")&lt;br /&gt;
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS&lt;br /&gt;
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645&lt;br /&gt;
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1&lt;br /&gt;
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)&lt;br /&gt;
TABLESPACE "SYSTEM"&lt;br /&gt;
&lt;br /&gt;
SQL&amp;gt; DROP INDEX SYS.I_JOB_NEXT;&lt;br /&gt;
SQL&amp;gt; CREATE INDEX "SYS"."I_JOB_NEXT" ON "SYS"."JOB$" ("NEXT_DATE") TABLESPACE "SYSTEM";&lt;br /&gt;
&lt;br /&gt;
It works. Previously, I thought that 'REBUILD' command internaly drop an object and recreate it. But, now I need to explore 'How rebuild command works ?'.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>ORA-01591: lock held by in-doubt distributed transaction string</title><link>http://shaharear.blogspot.com/2011/10/ora-01591-lock-held-by-in-doubt.html</link><category>ERROR: ORA-</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Sun, 16 Oct 2011 16:57:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-8774073762964882674</guid><description>&lt;span style="font-weight: bold;"&gt;Cause: &lt;/span&gt;    Trying to access resource that is locked by a dead two-phase commit transaction that is in prepared state.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Action:&lt;/span&gt;     DBA should query the DBA_PENDING_TRANSACTIONS and DBA_2PC_PENDING, and attempt to repair network connection(s) to coordinator and commit point. If timely repair is not possible, DBA should contact end user for rollback/commit the transection.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sqlplus / as sysdba;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; SELECT * FROM DBA_2PC_PENDING;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; ROLLBACK FORCE LOCAL_TRAN_ID;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; commit;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; alter system enable distributed recovery;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL&amp;gt; execute dbms_transaction.purge_lost_db_entry('LOCAL_TRAN_ID');&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SQL &amp;gt; commit;&lt;br /&gt;&lt;br /&gt;For more details plese go through this &lt;a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/ds_txnman007.htm#i1008132"&gt;document &lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Table Comparison and Synchronisation</title><link>http://shaharear.blogspot.com/2011/07/table-comparison-and-synchronisation.html</link><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Mon, 25 Jul 2011 19:04:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-3446650202234852401</guid><description>&lt;div class="gmail_quote"&gt;If you are managing more than one databases for same application, it is very common that you need to compare one table ( say scott.employee) in two different databases. I think, we had previous experiences to do such job :) . The simplest way is just minus two tables. Like&lt;br /&gt;&lt;br /&gt;1. Two different tables In same DB - &lt;span style="font-style: italic;"&gt;SELECT * FROM table1 minus SELECT * FROM table2;&lt;/span&gt;&lt;br /&gt;2. Same table in two different DB - &lt;span style="font-style: italic;"&gt;SELECT * FROM table1 minus SELECT * FROM table2@remote_db;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But this simple task can be time consuming if your tables are very big (say 1000000+ records). If targeted tables do not contain BLOB,CLOB or Long data type columns, you can easily use DBMS_COMPARISON, a new package introduce in Oracle 11g, to compare them. More over this package also provide Synchronization to remove miss match records in targeted tables. For details please go through &lt;a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_comparison.htm" target="_blank"&gt;Oracle Documentations&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here we are going to compare and synchronise 'employee' table in two different DB.&lt;br /&gt;&lt;br /&gt;Requirement: A database link between host (i.e, where these script will be run) and remote DB.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step One&lt;/b&gt;: Create comparison Task&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;BEGIN  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_COMPARISON.CREATE_COMPARISON(&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;comparison_name =&amp;gt; 'compare_employee'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, schema_name     =&amp;gt; 'SCOTT'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, object_name     =&amp;gt; 'EMPLOYEE'  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, dblink_name     =&amp;gt; 'db_link_to_remote'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  , remote_schema_name=&amp;gt;'SCOTT'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, remote_object_name=&amp;gt;'EMPLOYEE'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; /&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you wish to compare two different table in same DB, set dblink_name     =&amp;gt; NULL,  object_name     =&amp;gt; 'table1' and remote_object_name=&amp;gt;'table2'&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step Two&lt;/b&gt;: Execute comparison Task&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DECLARE  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;consistent BOOLEAN;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_info DBMS_COMPARISON.COMPARISON_TYPE;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;BEGIN  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; consistent := DBMS_COMPARISON.COMPARE( comparison_name =&amp;gt;'compare_employee', scan_info=&amp;gt; scan_info, perform_row_dif =&amp;gt; TRUE);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;   DBMS_OUTPUT.PUT_LINE('Scan ID: '||scan_info.scan_id);  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; IF consistent=TRUE THEN DBMS_OUTPUT.PUT_LINE('No differences found.');  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ELSE &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  DBMS_OUTPUT.PUT_LINE('Differences were found.'); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  END IF;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step Three&lt;/b&gt;: See how may difference you got&lt;br /&gt;&lt;br /&gt;col COMPARISON_NAME format a15;&lt;br /&gt;col SCHEMA_NAME format a15;&lt;br /&gt;col OBJECT_NAME format a15;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT s.scan_id ,c.COMPARISON_NAME,c.SCHEMA_NAME,c.OBJECT_NAME ,s.CURRENT_DIF_COUNT&lt;br /&gt;FROM USER_COMPARISON c,USER_COMPARISON_SCAN_SUMMARY s&lt;br /&gt;WHERE  c.COMPARISON_NAME = s.COMPARISON_NAME AND s.scan_id = 514;&lt;span style="font-style: italic;"&gt; &lt;/span&gt; (this number is a out put of step two)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step Four&lt;/b&gt;: Synchronise Remote table with host table.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DECLARE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_info DBMS_COMPARISON.COMPARISON_TYPE;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_COMPARISON.CONVERGE (comparison_name  =&amp;gt; 'compare_employee',&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_id =&amp;gt; 506,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;scan_info =&amp;gt; scan_info, --this number is a out put of step two&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  converge_options =&amp;gt; DBMS_COMPARISON.CMP_CONVERGE_LOCAL_WINS);  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_OUTPUT.PUT_LINE('Local Rows Merged: '||scan_info.loc_rows_merged);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_OUTPUT.PUT_LINE('Remote Rows Merged: '||scan_info.rmt_rows_merged);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  DBMS_OUTPUT.PUT_LINE('Local Rows Deleted: '||scan_info.loc_rows_deleted);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;DBMS_OUTPUT.PUT_LINE('Remote Rows Deleted: '||scan_info.rmt_rows_deleted);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can also Synchronise Host table by using Remote table, please visit given link.&lt;br /&gt;&lt;br /&gt;I hope you all will enjoy this exiting new package of Oracle 11g.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Traveling past with Log Miner</title><link>http://shaharear.blogspot.com/2011/07/traveling-past-with-log-miner.html</link><category>Audit</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Mon, 11 Jul 2011 14:55:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-7862559796486409915</guid><description>Some times you may wish to see what happen in recent past. In a beautiful morning, you may discover that a misshape occure in your database :(. Unfortunately you did not enabled any auditing options earlier.&lt;br /&gt;&lt;br /&gt;If your database is in &lt;span style="color: rgb(255, 0, 0);"&gt;archivelog&lt;/span&gt; mod and &lt;span style="color: rgb(204, 0, 0);"&gt;supplemental log&lt;/span&gt; is enabled then '&lt;span style="font-style: italic; color: rgb(255, 102, 102);"&gt;Log Miner&lt;/span&gt;' can save the day !  Oracle Log Miner is also capable of mining redo log, archive log of remote DB. Please see &lt;a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#sthref1875"&gt;Oracle Utility Document&lt;/a&gt; for details.&lt;br /&gt;&lt;br /&gt;In this post, we only consider a scenario in which Source DB and Mining DB is same. Lets describe how you can do this&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;STEP 1 : Create Log Miner User&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;CREATE USER logminer_adm identified by logminer_adm;&lt;br /&gt;&lt;br /&gt;GRANT resource,connect to logminer_adm;&lt;br /&gt;GRANT EXECUTE_CATALOG_ROLE,DBA to logminer_adm;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 2 : Enable Supplemental Login&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;Check whether supplemental login is enabled&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If not, then you can't mine all transections. So enable it for future and follow the remaining steps to mine a subset of all transections.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 0, 0);"&gt;Step 3:  Add Archieve Log Files to Log Miner&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:100%;"  &gt;&lt;span style="font-size:85%;"&gt;ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME =&amp;gt;'/u/archivelog/2011_07_10/o1_mf_1_470_71m4jv90_.arc', OPTIONS =&amp;gt; DBMS_LOGMNR.NEW);&lt;br /&gt;EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LOGFILENAME =&amp;gt;'/u/archivelog/2011_07_10/o1_mf_1_471_71m4kn09_.arc', OPTIONS =&amp;gt; DBMS_LOGMNR.ADDFILE);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;You can add as much files as you need&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 4: Start Log Miner&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;EXECUTE DBMS_LOGMNR.START_LOGMNR(STARTTIME =&amp;gt;'10-JUL-2011 19:50:00',ENDTIME =&amp;gt; '10-JUL-2011 19:55:00',OPTIONS =&amp;gt; DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;+DBMS_LOGMNR.CONTINUOUS_MINE);&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 5: View What Happen Last Night :)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;SELECT SEG_OWNER ,OPERATION, SQL_REDO, SQL_UNDO&lt;br /&gt;FROM V$LOGMNR_CONTENTS&lt;br /&gt;WHERE  SEG_OWNER = 'SYS';&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;Step 6: Stop Log Miner Session&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;&lt;br /&gt;EXECUTE DBMS_LOGMNR.END_LOGMNR;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>DATA PUMP: Network mode import</title><link>http://shaharear.blogspot.com/2011/07/data-pump-network-mode-import.html</link><category>Export-Import</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Sat, 2 Jul 2011 13:21:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-6588658532256139295</guid><description>Some time we need to copy one schema from one DB machine to another machine or copy one schema as schema (i.e. remap schema) in same DB. The simplest way is to &lt;br /&gt;&lt;br /&gt; &lt;span style="font-style: italic;"&gt;(a) &lt;/span&gt;export required schema, move dump to remote DB and import [copy in 2 DB]&lt;br /&gt;&lt;br /&gt; &lt;span style="font-style: italic;"&gt;(b)&lt;/span&gt; export required&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" class="J-JK9eJ-PJVNOc"&gt;&lt;/span&gt; schema and import the dump with schema replace option [copy in same DB]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold;"&gt;Scenario ONE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Suppose the source schema is too small (say 1-3 GB) the above process is time consuming and labours compare with task requirements.&lt;br /&gt;&lt;br /&gt; &lt;span style="font-weight: bold;"&gt;Scenario TOW&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; Suppose the source schema is too big (say 100 GB+) and there is not enough disk space to store the 100G size dump.&lt;br /&gt;&lt;br /&gt; In above cases you can use the option of network import. But you need to consider that network import is a slower process because all the data should be travel in connection cable if your target is coping a schema in two different DB machine.&lt;br /&gt;&lt;br /&gt; Lets describe how we can achieve this. we move user_info schema from source db to remote db. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 1: grant exp_full_database role to socre shcema [IN REMOTE DB]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;conn system/pass; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;GRANT EXP_FULL_DATABASE to user_info;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 2: [IN DESTINATION DB] Create destination user and grant necessary roles&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;conn system/pass;&lt;br /&gt;CREATE USER user_info&lt;br /&gt;IDENTIFIED BY pass&lt;br /&gt;DEFAULT TABLESPACE USER&lt;br /&gt;TEMPORARY TABLESPACE TEMP;&lt;br /&gt;&lt;br /&gt;GRANT CONNECT , RESOURCE TO user_info;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 3: [IN DESTINATION DB] grant read/write on dump directory&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;conn system/pass;&lt;br /&gt;&lt;br /&gt;GRANT read,write on DIRECTORY dump_directory to user_info;&lt;br /&gt;&lt;br /&gt;Network import does not requer any dump file. This directory is only requer to write the import log file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 4: [IN DESTINATION DB] create public DB Link &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;conn system/pass;&lt;br /&gt;CREATE PUBLIC DATABASE LINK SATURN&lt;br /&gt;connect to user_info identified by pass&lt;br /&gt;using '(DESCRIPTION=(&lt;br /&gt;ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=remote_db)&lt;br /&gt;(PORT=1521)))&lt;br /&gt;(CONNECT_DATA=(SERVICE_NAME=orcl.oracle.com)&lt;br /&gt;(server=DEDICATED)))';&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;STEP 5: [IN DESTINATION DB MACHINE] execute impdp &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;impdp user_info/pass directory=dump_dir network_link=SATURN  logfile=net_import_proddev.log EXCLUDE=GRANT,STATISTICS,SYNONYM,DB_LINK REMAP_SCHEMA=USER_INFO:USER_INFO&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Multiplex online Redo Logfile</title><link>http://shaharear.blogspot.com/2011/05/multiplex-online-redo-logfile.html</link><category>Oracle Administration and Maintenance</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 4 May 2011 09:37:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-3501506747169825047</guid><description>It is important to have multiple (at list two) copy of each online redo logfile. To avoid the disaster of disk failure, it is recommended to place each member of a specific online redo logfile group in different disk.&lt;br /&gt;&lt;br /&gt;To view to current online redo logfile group members&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SELECT GROUP#,STATUS,MEMBER FROM V$LOGFILES;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Suppose we have disk01 (mount point &lt;span style="font-style: italic;"&gt;/u01&lt;/span&gt; ) that contains current online redolog files .To add member in  redo logfile group 1,2 and 3 in disk02 ( mount point &lt;span style="font-style: italic;"&gt;/u02&lt;/span&gt; )&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ALTER DATABASE ADD LOGFILE MEMBER '/u02/redo01.log' TO GROUP 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ALTER DATABASE ADD LOGFILE MEMBER '/u02/redo02.log' TO GROUP 2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt; ALTER DATABASE ADD LOGFILE MEMBER '/u02/redo03.log' TO GROUP 3;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Track Database Growth</title><link>http://shaharear.blogspot.com/2011/03/track-database-growth.html</link><category>Oracle Administration and Maintenance</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Mon, 21 Mar 2011 10:03:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-1716149016844763705</guid><description>Some time it become very important to monitor your database growth specially in test database machines. Usually these machines have very limited disk space.&lt;br /&gt;Thus, tracking the consumption of disk space is one of the frequent tasks in administrative checklist. Here is a SQL script that gives you the current size of database and average disk space consumed in each day.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;SELECT b.tsname tablespace_name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, MAX(b.used_size_mb) cur_used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;, round(AVG(inc_used_size_mb),2)avg_increas_mb &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;FROM (&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  SELECT a.days,a.tsname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  , used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  , used_size_mb - LAG (used_size_mb,1)  OVER ( PARTITION BY a.tsname ORDER BY a.tsname,a.days) inc_used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  FROM (&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      SELECT TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY') days &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       ,ts.tsname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       ,MAX(round((tsu.tablespace_usedsize* dt.block_size )/(1024*1024),2)) used_size_mb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      FROM DBA_HIST_TBSPC_SPACE_USAGE tsu&lt;br /&gt;      , DBA_HIST_TABLESPACE_STAT ts &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       ,DBA_HIST_SNAPSHOT sp, DBA_TABLESPACES dt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      WHERE tsu.tablespace_id= ts.ts# AND tsu.snap_id = sp.snap_id&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;       AND ts.tsname = dt.tablespace_name  AND sp.begin_interval_time &gt; sysdate-7&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      GROUP BY TO_CHAR(sp.begin_interval_time,'MM-DD-YYYY'), ts.tsname &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;      ORDER BY ts.tsname, days&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  ) a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;) b GROUP BY b.tsname ORDER BY b.tsname;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>ORA-14519 Conflicting tablespace blocksizes while importing partition tables</title><link>http://shaharear.blogspot.com/2011/01/ora-14519-conflicting-tablespace.html</link><category>ERROR: ORA-</category><category>Oracle Tips And Tricks</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Wed, 26 Jan 2011 16:34:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-144552125397658709</guid><description>&lt;style type="text/css"&gt;p { margin-bottom: 0.08in; }&lt;/style&gt;   &lt;p  style="margin-bottom: 0in;font-family:verdana;"&gt;ORA-14519: Conflicting tablespace blocksizes for table : Tablespace T2 block size 16384 [partition specification] conflicts with previously specified/implied tablespace T1 block size 8192 [object-level default]&lt;/p&gt;  &lt;p  style="margin-bottom: 0in;font-family:verdana;"&gt;Well :) the error massage clearly indicate that I am trying to create a partition table in more than one tablespaces where the blocksize of the tablespaces are different. We all know that &lt;span style="font-style: italic; font-weight: bold;"&gt;table partitions can not be placed in different blocksize tablespaces&lt;/span&gt;. Though I know this and not did this mistake before, I get this error when I am trying to make a replica schema in local test database.  &lt;/p&gt;  &lt;p face="verdana" style="margin-bottom: 0in;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p face="verdana" style="margin-bottom: 0in;"&gt;I took dump by using &lt;span style="font-style: italic; font-weight: bold;"&gt;EXPDP&lt;/span&gt; without any error and get the above error when try to import it by using &lt;span style="font-style: italic;"&gt;REMAP_SCHEMA&lt;/span&gt; option of &lt;span style="font-weight: bold; font-style: italic;"&gt;IMPDP&lt;/span&gt;. It is really annoying to get such error that can not be explainable. All of my table partitions are placed in a single tablespace but the error message says that I am trying to place table partitions in two tablespaces where their blocksize is different ! It sounds simply horrible.&lt;/p&gt;    &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;But at the end of a long research :) I have found the mistake.The user's default tablespace is T1 [8k blocksize] and I create the table in tablespace T2 [16K blocksize] just like this -&lt;br /&gt;&lt;/p&gt;    &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;CREATE TABLE TEST (ID NUMBER (10), TEXT VARCHAR2(50)&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) PARTITION BY RANGE (ID) (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION TEST_PART_1 VALUES LESS THAN (100001) TABLESPACE T2 ,&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION "TEST_PART_2" VALUES LESS THAN (MAXVALUE) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;);&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;This script create 2 table partitions of TEST table in T2 tablespace but unfortunately the default tablespace attribute of TEST table set to T1 (As I did not mansion default table space of table TEST when I create it. So ORACLE set this attribute same as user's default tablespace). See! Sometime ORACLE does something smartly that can cause stupid scenario. IF you want to see this unbelievable thing, just generate the table's SQL. You will see this&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;   &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;CREATE TABLE TEST (ID NUMBER (10),TEXT VARCHAR2(50)&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) &lt;span style="color: rgb(255, 102, 102);"&gt;TABLESPACE T1&lt;/span&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION BY RANGE (ID) (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION TEST_PART_1 VALUES LESS THAN (100001) TABLESPACE T2 ,&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION "TEST_PART_2" VALUES LESS THAN (MAXVALUE) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;);&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;This sturdiness of oracle cause ORA-14519 when I  tryed to import  TEST table because oracle can't create a partition table in  different blocksize tablespaces.&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;So The solution is simple; mention default tablespace when you create a partition table. Just like this&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;CREATE TABLE TEST (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;ID NUMBER (10),&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;TEXT VARCHAR2(50)&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION BY RANGE (ID) (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION TEST_PART_1 VALUES LESS THAN (100001) TABLESPACE T2 ,&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;PARTITION "TEST_PART_2" VALUES LESS THAN (MAXVALUE) TABLESPACE T2&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;);  &lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;[ It is not mandatory that all tablespace should be same (t2 in this case). You can put 3 different tablespace but their blocksize should be same.]&lt;/p&gt;   &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;But, what is the solution for already created partition tables ? Well, the solution is very simple, just change the default tablespace attribute of your partition tables that are already created. Here is a script to identify the problematic tables.&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;SELECT * FROM (&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;SELECT x.table_name, x.def_tablespace_name&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;, (SELECT block_size from user_tablespaces where tablespace_name=x.def_tablespace_name) df  &lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;, x.tablespace_name  &lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;, (SELECT block_size from user_tablespaces where tablespace_name = x.tablespace_name) tb&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;FROM (&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;SELECT distinct t.table_name, t.def_tablespace_name, p.tablespace_name&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;FROM user_part_tables t, user_tab_partitions p&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;WHERE t.table_name = p.table_name&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;) x ) k WHERE k.tb &lt;&gt; k.df;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;Then reset the default tablespace attribute&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-style: italic; font-family: verdana;"&gt;ALTER TABLE TEST MODIFY default attributes TABLESPACE T2;&lt;/p&gt;  &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;Now take dump and apply it without facing &lt;span style="font-weight: bold;"&gt;ORA-14519&lt;/span&gt; !&lt;/p&gt; &lt;p style="margin-bottom: 0in; font-family: verdana;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>PL/SQL - Operator  Precedence</title><link>http://shaharear.blogspot.com/2010/10/plsql-operator-precedence.html</link><category>Oracle Tips And Tricks</category><category>SQL PL/SQL Tips</category><author>noreply@blogger.com (Mohammad Hasan Shaharear)</author><pubDate>Fri, 8 Oct 2010 14:50:00 +0600</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5794742462833718439.post-769613794650570150</guid><description>Hi all, It has been almost an year since I posted a topic in this blog. After a 1 year study break, I back to my usual job and hopfully I am become regular in this blog again.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In SQL or PL/SQL we use several operators. Some are mathematical, logical and comparison operatiors. Oracle follow a order of precedence when execute an expression that contains more than one operators. If operatiors with same precidence are occured then it does not follow any order. Otherwise Oracle maintain the following order of precedence of operators.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Order |------------|        Operator     |------------|        Operation&lt;br /&gt;1         |------------|                     **        |------------|        exponentiation&lt;br /&gt;2         |------------|                +,                     |------------|        identity, negation&lt;br /&gt;3         |------------|                 *, /                   |------------|        multiplication, division&lt;br /&gt;4         |------------|              +, -, ||             |------------|        addition, subtraction, concatenation&lt;br /&gt;5     |------------|          =, &lt;, &gt;, &lt;=, &gt;=,            |------------|        comparison&lt;br /&gt;   &lt;&gt;, !=, ~=, ^=, IS NULL, LIKE,&lt;br /&gt;   BETWEEN, IN&lt;br /&gt;6     |------------|        NOT                              |------------|        logical negation&lt;br /&gt;7     |------------|        AND                              |------------|        conjunction&lt;br /&gt;8     |------------|        OR                                 |------------|        inclusion&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For example, when NOT, AND and OR operators are used in the same statement NOT is evaluated first, then AND and finally OR.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-7671704941950548";
/* 250x250, created 4/28/08 */
google_ad_slot = "4284076706";
google_ad_width = 250;
google_ad_height = 250;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item></channel></rss>