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

<channel>
	<title>Oracle Database Tips blog &#187; DB Links</title>
	<atom:link href="http://oracle-database-tips.com/wp/category/dblinks/feed" rel="self" type="application/rss+xml" />
	<link>http://oracle-database-tips.com/wp</link>
	<description>News for Oracle professionals</description>
	<lastBuildDate>Fri, 03 Feb 2012 10:37:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Troubleshoot Oracle database links</title>
		<link>http://oracle-database-tips.com/wp/dblinks/troubleshoot-oracle-database-links</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/troubleshoot-oracle-database-links#comments</comments>
		<pubDate>Fri, 23 Oct 2009 12:13:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[database name]]></category>
		<category><![CDATA[first tip]]></category>
		<category><![CDATA[host name]]></category>
		<category><![CDATA[oracle9]]></category>
		<category><![CDATA[production server]]></category>
		<category><![CDATA[test server]]></category>
		<category><![CDATA[tns]]></category>
		<category><![CDATA[tnsnames]]></category>
		<category><![CDATA[troubleshoot oracle database link]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=126</guid>
		<description><![CDATA[Read up here to find solutions to common db link setup mistakes and errors.

]]></description>
			<content:encoded><![CDATA[<div id="calltoaction" class="medium">Always test these &#8216;troubleshoot oracle database link errors&#8217; commands on a test server<br />
before implementing them on a production server.</div>
<p><!-- ============================================================================================================================================================ --> There are a number of errors that you can face when working with database          links in Oracle.</p>
<p>Below are a list of some of the more common ones and suggestions on how to troubleshoot oracle database link errors .</p>
<ul>
<li><a href="#TIP">Oracle10 Tip</a></li>
<li><a href="#ORA02021">ORA-02021</a></li>
<li><a href="#ORA02080">ORA-02080</a></li>
<li><a href="#ORA02085">ORA-02085</a></li>
<li><a href="#ORA12154">ORA-12154</a></li>
<li><a href="#ORA12224">ORA-12224</a></li>
<li><a href="#ORA12305">ORA-12305</a></li>
</ul>
<h3>Background</h3>
<p>What happens during database link usage ?<br />
Some information to help you troubleshoot oracle database link errors.<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; select * from dual@remotedb;

D
-
X</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div >
<li> Oracle resolves the dblink name to a host name, using the value it can          find in the local server&#8217;s tnsnames.ora file.</li>
<li> It connects to this host&#8217;s listener via TCP/IP (using whichever naming          resolution is in place at OS level).</li>
<li> The remote listener for the relevant port resolves the SID or Service          Name as defined in its listener.ora and completes the connection to the          database.</li>
<p><strong>How do you find or create the correct entry in tnsnames.ora ?</strong></p>
<li> Find your server&#8217;s tnsnames.ora, it will usually be in $ORACLE_HOME/network/admin.</li>
<li> Make sure you do not have a $TNS_ADMIN environment variable set, if you          do, your tnsnames.ora will be in that directory.</li>
<li>Scan it and look for an alias which contains the hostname and database          name of the remote database you want to access.</li>
<li> Test its validity by using sql*plus on your local server and connecting          to that alias with the username and password you intend using in your          database link.</li>
<p><a id="TIP" name="TIP"></a></p>
<h3>Oracle10 Tip</h3>
<p>The first tip does not have an error associated with it, but is just          a tip:</p>
<p>If you have recently upgraded your database from Oracle9 to Oracle10          and your database links are no longer<br />
working, simply recreate them as a first step to troubleshoot oracle database          link errors .</p>
<h3><a id="ORA02021" name="ORA02021"></a>ORA-02021: DDL operations are not allowed on a remote database</h3>
<p>Self-explanatory, no need to troubleshoot oracle database link errors any further :</p>
<p>Do not try to run a DDL command through a database link.<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; alter table dept@remotedb add column
     (manager varchar2(30));
alter table dept@remotedb add column
     (manager varchar2(30))
                 *
ERROR at line 1:
ORA-02021: DDL operations are not allowed on
a remote database</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> <a id="ORA02080" name="ORA02080"></a></p>
<h3>ORA-02080: database link is in use</h3>
<p>This can come up when you want to close a db link.</p>
<p>Solution: commit or rollback the transaction, then close the database          link.<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; alter session close database link remotedb;
ERROR:
ORA-02080: database link is in use

SQL&gt; commit;

Commit complete.

SQL&gt; alter session close database link remotedb;

Session altered.</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> <a id="ORA02085" name="ORA02085"></a></p>
<h3>ORA-02085 : database link xxx connects to yyy</h3>
<p>If your local database&#8217;s &#8216;GLOBAL_NAMES&#8217; initialization parameter is set          to true, you will receive the ORA-02085 error when USING the db link:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; connect scott/tiger
Connected

SQL&gt; create database link remotedb connect to scott
     identified by tiger using 'otherremotedb';

Database link created.

SQL&gt; select * from dual@remotedb;
select * from dual@remotedb
                   *
ERROR at line 1:
ORA-02085 : database link REMOTEDB connects to
            OTHERREMOTEDB</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --><br />
<strong>Solution:</strong><br />
On your local database, connected as sysdba,<br />
see what your parameter GLOBAL_NAMES is set to :</p>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; show parameter global_names

NAME             TYPE        VALUE
---------------- ----------- ----------
global_names     boolean     TRUE

SQL&gt; alter system set global_names=false
     scope=both;

System altered.

SQL&gt; connect scott/tiger

Connected.
SQL&gt; select * from dual@remotedb;

D
-
X</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> Tip : if you cannot change your local database&#8217;s GLOBAL_NAMES setting,<br />
change the name of the dblink to the global_name of the remote database.<br />
To find out what it is , log in to the remote database as sysdba:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; select * from global_name;

GLOBAL_NAME
--------------------------------
REMOTEDB</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> Another problem to look into when you troubleshoot oracle database link errors like ORA-02085<br />
is a difference in domain          names between your local database and the remote database.<br />
This is only a problem if you do not specify the domain name in your db          link name.</p>
<p>For example, The remote database&#8217;s domain name is world.net and your          local database&#8217;s domain name is world.com</p>
<p>You create a db link as follows:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; create database link remotedb
      using 'remotedb';
Database link created.

SQL&gt; select * from dual@remotedb;
ORA-2085 "database link REMOTEDB.WORLD.COM
         connects to REMOTEDB.WORLD.NET"</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --><br />
To resolve this , drop the db link and recreate it by specifying the correct domain name:</p>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; drop database link remotedb;
Database link dropped.

SQL&gt; create database link remotedb.world.net
     using 'remotedb';
Database link created.

SQL&gt; select * from dual@remotedb;

D
-
X</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> Alternatively you can change the global name of the remote database:</p>
<p>See what it is first:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; connect / as sysdba
Connected

SQL&gt; select * from global_name;

GLOBAL_NAME
------------
REMOTEDB

SQL&gt;alter database rename global_name
    to remotedb.world.com;
Database altered.

SQL&gt; select * from global_name;

GLOBAL_NAME
-------------------
REMOTEB.WORLD.COM</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --><br />
Now you can create the db link on the local server without specifying the domain name:</p>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; drop database link remotedb;
Database link dropped.

SQL&gt; create database link remotedb
      using 'remotedb';
Database link created.

SQL&gt; select * from dual@remotedb;

D
-
X</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> <a id="ORA12154" name="ORA12154"></a></p>
<h3>ORA-12154 : TNS:could not resolve service name</h3>
<p>When you troubleshoot oracle database link errors like ORA-12154, you need to look into your networking configuration files.</p>
<li>Double-check the alias you are using in your database link against a          functional one from the local server&#8217;s tnsnames.ora.</li>
<li>Are you looking at the correct tnsnames.ora ?</li>
<li> If you have multiple Oracle Homes on your local server, you could be looking          at the wrong one.</li>
<li>Also check for the existence of the $TNS_ADMIN environment variable, the          correct tnsnames.ora file will be there, not where you expected it to          be.</li>
<li>The best test is to copy and paste the alias from your tnsnames.ora file,<br />
then do an sql*plus connection to it with the username and password you          are using in the db link.</li>
<li>Once that is checked, retest your database link to see if the ORA-12154 has gone away.</li>
<p><a id="ORA12224" name="ORA12224"></a></p>
<h3>ORA-12224 : TNS: no listener</h3>
<p>Make sure the remote server&#8217;s listener is running and listening on the          correct port as shown in your local server&#8217;s tnsnames.ora.<br />
Fix what is wrong and retry the db link query to see if the ORA-12224 is resolved.</p>
<p><a id="ORA12305" name="ORA12305"></a></p>
<h3>ORA-12305 : TNS:listener could not resolve SID given in connect descriptor</h3>
<p>Make sure the remote server&#8217;s listener is listening for the SID or service          name as shown in your local server&#8217;s tnsnames.ora.<br />
To check:<br />
Log onto the remote server and see what the listener is listening for          <em>: lsnrctl services</em> or <em>lsnrctl status </em></p>
<p><!-- ============================================================================================================================================================ --></p>
<h3>Recommended reading:</h3>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14231%2Fds_admin.htm%23i1007820&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Ftroubleshoot_oracle_database_link_errors.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1007820" target="_blank">Oracle Online Documentation : Administrator&#8217;s Guide, Creating Database Links</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14200%2Fstatements_5005.htm%23SQLRF01205&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Ftroubleshoot_oracle_database_link_errors.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#SQLRF01205" target="_blank">Oracle Online Documentation : SQL Reference, Create Datatabase Link syntax</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fasktom.oracle.com%2Fpls%2Fasktom%2Ff%3Fp%3D100%3A11%3A0%3A%3A%3A%3AP11_QUESTION_ID%3A456820211101&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Ftroubleshoot_oracle_database_link_errors.html'); return false;" href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:456820211101" target="_blank">AskTom: troubleshoot oracle database link errors page</a></li>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/troubleshoot-oracle-database-links/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manage Oracle database links</title>
		<link>http://oracle-database-tips.com/wp/dblinks/manage-oracle-database-links</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/manage-oracle-database-links#comments</comments>
		<pubDate>Fri, 23 Oct 2009 12:10:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[commited]]></category>
		<category><![CDATA[communications protocol]]></category>
		<category><![CDATA[database link]]></category>
		<category><![CDATA[database query]]></category>
		<category><![CDATA[dblink]]></category>
		<category><![CDATA[manage oracle database links]]></category>
		<category><![CDATA[open cursors]]></category>
		<category><![CDATA[open database]]></category>
		<category><![CDATA[owner id]]></category>
		<category><![CDATA[public database]]></category>
		<category><![CDATA[s communications]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=124</guid>
		<description><![CDATA[How many database links are in existence on your database, how many are in use ? ]]></description>
			<content:encoded><![CDATA[<div class="large"><strong>Know your open links</strong></div>
<p><!-- ============================================================================================================================================================ -->Once you have created and made use of a database link in Oracle,<br />
you might want to keep an eye on the number of concurrent open database links<br />
in your database so you can tune the <em>open_links</em> initialization parameter.</p>
<p>Read more <a href="http://www.oracle-database-tips.com/limit_oracle_database_links.html">here</a> on limiting concurrent open links.</p>
<p>You will need to query <em>v$dblink</em> to see how many links are open in your          session:</p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; select in_transaction, count(*) from v$dblink
     group by in_transaction;

IN_   COUNT(*)
--- ----------
YES          1</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   -->Here are some interesting columns and descriptions of <em>v$dblink</em>:</p>
<pre class="large">db_link           Db link name
owner_id          Owner name
logged_on         Is the database link currently logged on?
protocol          Dblink's communications protocol
open_cursors      Are there any cursors open for the db link ?
in_transaction    Is the db link part of a transaction which
                  has not been commited or rolled back yet ?
update_sent       Was there an update on the db link ?</pre>
<div class="large"><strong>dba_db_links</strong></div>
<p>To gather information on all database links in your database, query <em>dba_db_links</em>.<br />
You will need dba privileges to see this view, the alternatives are <em>user_db_links</em> and <em>all_db_link</em>s.</p>
<p>A user who does not have dba privileges can query <em>all_db_links</em> to see<br />
which db links are available to him.</p>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; select * from dba_db_links;

OWNER      DB_LINK     HOST       CREATED
---------- ----------  ---------- ----------
SCOTT      REMOTEDB    remotedb   23-feb-2008 23:59:05</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   -->Some interesting columns:</p>
<pre class="large">owner           User who owns the db link,
                will state 'PUBLIC' if it is a public database link.
db_link         Db link name.
username        The username that was specified if it was hardcoded
                during the create statement, null if not specified
                during the create statement.
host            The tnsnames alias specified during the create
                statement.
created         Date and time of link creation.</pre>
<p><!-- ============================================================================================================================================================ --></p>
<h3>Recommended reading:</h3>
<div id="content">
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14231%2Fds_admin.htm%23i1007820&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fmanage_oracle_database_links.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1007820" target="_blank">Oracle Online Documentation : Administrator&#8217;s Guide, Creating Database Links</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14200%2Fstatements_5005.htm%23SQLRF01205&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fmanage_oracle_database_links.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#SQLRF01205" target="_blank">Oracle Online Documentation : SQL Reference, Create Datatabase Link syntax</a></li>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/manage-oracle-database-links/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limit Oracle database links per session</title>
		<link>http://oracle-database-tips.com/wp/dblinks/limit-oracle-database-links-per-session</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/limit-oracle-database-links-per-session#comments</comments>
		<pubDate>Fri, 23 Oct 2009 12:09:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[database application]]></category>
		<category><![CDATA[documentation sql]]></category>
		<category><![CDATA[initialization parameter]]></category>
		<category><![CDATA[limit db links]]></category>
		<category><![CDATA[line 1]]></category>
		<category><![CDATA[link syntax]]></category>
		<category><![CDATA[maximum allowable number]]></category>
		<category><![CDATA[open_links]]></category>
		<category><![CDATA[pfile]]></category>
		<category><![CDATA[real time]]></category>
		<category><![CDATA[scope]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=122</guid>
		<description><![CDATA[Limit the number of allowable db links per session for your database]]></description>
			<content:encoded><![CDATA[<div class="large"><strong> Determine the maximum allowable number of database links<br />
per session in your database</strong></div>
<p><!-- ============================================================================================================================================================ -->Each session in your database has a limited number of database links that          can be opened at the same time.</p>
<p>This number is determined by a database-wide initialization parameter:          OPEN_LINKS.</p>
<p>The default value is set to 4.</p>
<p>If it is set to 0, distributed transactions are not allowed.</p>
<p>If you are expecting your transactions to have a maximum of 3 database          links open concurrently, set this parameter to 3 or higher.</p>
<p>Do not set it too high, it is better for the application to close database          links when no longer in use than to change the parameter to a high number.</p>
<p>OPEN_LINKS cannot be modified in real-time, so you will have to change          it in the spfile or pfile and bounce the database.<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; alter system set open_links=10 scope=both;
alter system set open_links=0 scope=both
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter
cannot be modified

SQL&gt; alter system set open_links=10 scope=spfile;

System altered.</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> If you are not sure how many database links are opened up concurrently          by your session&#8217;s database application, you can query v$dblink.</p>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; select in_transaction, count(*) from v$dblink
     group by in_transaction;

IN_   COUNT(*)
--- ----------
YES          1</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> <!-- ============================================================================================================================================================ --></p>
<h3>Recommended reading:</h3>
<div id="content">
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14231%2Fds_admin.htm%23i1007820&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Flimit_oracle_database_links.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1007820" target="_blank">Oracle Online Documentation : Administrator&#8217;s Guide, Creating Database Links</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14200%2Fstatements_5005.htm%23SQLRF01205&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Flimit_oracle_database_links.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#SQLRF01205" target="_blank">Oracle Online Documentation : SQL Reference, Create Datatabase Link syntax</a></li>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/limit-oracle-database-links-per-session/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide Oracle database link</title>
		<link>http://oracle-database-tips.com/wp/dblinks/hide-oracle-database-link</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/hide-oracle-database-link#comments</comments>
		<pubDate>Fri, 23 Oct 2009 12:07:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[2 ways]]></category>
		<category><![CDATA[database note]]></category>
		<category><![CDATA[hide oracle database link complexity]]></category>
		<category><![CDATA[note database]]></category>
		<category><![CDATA[optimal solution]]></category>
		<category><![CDATA[select count]]></category>
		<category><![CDATA[time response]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=118</guid>
		<description><![CDATA[Want to spare yourself the db link syntax in daily use ?
Hide it with a view or a synonym. ]]></description>
			<content:encoded><![CDATA[<p><!-- ============================================================================================================================================================ --></p>
<div class="large"><strong>Use a view or synonym to hide distributed database complexity<br />
from your user</strong></div>
<p>There are 2 ways you can hide the complexity involved with Oracle database          links from your user:<br />
create a <em>synonym</em> or a <em>view</em>.</p>
<p>This will allow your user to access the data she needs without worrying<br />
about the syntax requirements of database links.</p>
<p>Your user may even be unaware of the fact that she is accessing some          data in a remote database.</p>
<p>Note:<br />
Database links are notoriously slow, not an optimal solution for          applications needing real-time response.<br />
Expect the database link to cause a delay in accessing the remote data.</p>
<p>Here is an example of creating a synonym for scott&#8217;s database link.<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; create  synonym rem_emp for emp@remotedb;

Synonym created.

SQL&gt; select count(*) from rem_emp;

  COUNT(*)
----------
        14</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   -->The other method is to create a view on your remote database&#8217;s data.<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; create view v_emp as select * from emp@remotedb;

View created.

SQL&gt; select count(*) from v_emp;

  COUNT(*)
----------
        14</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<h3>Recommended reading:</h3>
<div id="content">
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14231%2Fds_admin.htm%23i1007820&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fhide_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1007820" target="_blank">Oracle Online Documentation : Administrator&#8217;s Guide, Creating Database Links</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14200%2Fstatements_5005.htm%23SQLRF01205&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fhide_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#SQLRF01205" target="_blank">Oracle Online Documentation : SQL Reference, Create Datatabase Link syntax</a></li>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/hide-oracle-database-link/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drop Oracle database link</title>
		<link>http://oracle-database-tips.com/wp/dblinks/drop-oracle-database-link</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/drop-oracle-database-link#comments</comments>
		<pubDate>Fri, 23 Oct 2009 12:05:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[Drop Oracle database link]]></category>
		<category><![CDATA[private database]]></category>
		<category><![CDATA[privilege]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[tiger]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=116</guid>
		<description><![CDATA[Drop Oracle database link syntax]]></description>
			<content:encoded><![CDATA[<div class="large"><strong>How to drop a database link </strong></div>
<p>Dropping a database link from your Oracle database is as easy as doing          the following:</p>
<p><strong>drop database link remotedb;</strong><br />
or<br />
<strong>drop public database link remotedb;</strong></p>
<p>You will need no other system privilege other than the &#8216;create database          link&#8217; privilege granted directly<br />
to your username or granted via a role to drop your own database link.</p>
<p>It is not possible to drop a database link belonging to another user.</p>
<p>If you try to specify another schema&#8217;s database link by qualifying it          with a name,<br />
Oracle will just look for a private database link in your schema with          a name<br />
which includes the other schema&#8217;s name and will not find it.</p>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --> To drop a public database link, you will need the system privilege &#8216;drop          public database link&#8217;.</p>
<p>For example:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; connect / as sysdba
Connected.

SQL&gt; drop database link scott.remotedb;
drop database link scott.remotedb
                   *
ERROR at line 1:
ORA-02024: database link not found

SQL&gt; connect scott/tiger
Connected.
SQL&gt; drop database link scott.remotedb;
drop database link scott.remotedb
                   *
ERROR at line 1:
ORA-02024: database link not found

SQL&gt; drop database link remotedb;

Database link dropped.</pre>
</div>
</div>
<p><strong> Recommended reading:</strong></p>
<div id="content">
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14231%2Fds_admin.htm%23i1007820&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fdrop_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1007820" target="_blank">Oracle Online Documentation : Administrator&#8217;s Guide, Creating Database Links</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14200%2Fstatements_5005.htm%23SQLRF01205&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fdrop_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#SQLRF01205" target="_blank">Oracle Online Documentation : SQL Reference, Create Datatabase Link syntax</a></li>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/drop-oracle-database-link/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use database links</title>
		<link>http://oracle-database-tips.com/wp/dblinks/use-database-links</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/use-database-links#comments</comments>
		<pubDate>Fri, 23 Oct 2009 12:04:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[boise]]></category>
		<category><![CDATA[db link]]></category>
		<category><![CDATA[db link usage syntax]]></category>
		<category><![CDATA[dml statements]]></category>
		<category><![CDATA[dname]]></category>
		<category><![CDATA[duration]]></category>
		<category><![CDATA[loc]]></category>
		<category><![CDATA[lt]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=113</guid>
		<description><![CDATA[Syntax to use an Oracle database link]]></description>
			<content:encoded><![CDATA[<p>Once a database link has been created<br />
you are now ready to select your data from the remote database referenced by   the db link.</p>
<p>The syntax is :</p>
<p>select &lt;column list&gt; from &lt;table&gt;@&lt;dblink name&gt;;</p>
<p>For example:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; select * from dept@remotedb;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   -->The database link is opened during the select (or other DML transaction)        and remains open for the duration of the session.<br />
After you close a session, the links that were active in the session are        automatically closed.</p>
<h3><a id="Close" name="Close"></a>Close a db link</h3>
<p>To explicitly close the database link , use the command below:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; alter session close database link remotedb;

Session altered.</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<h3>Using db links in other DML statements</h3>
<p>You can use insert/update/delete statements just as easily with database          links<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; select * from dept@remotedb;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

SQL&gt; insert into dept@remotedb (deptno,dname,loc)
  2  values (50,'MARKETING','BOISE');

1 row created.

SQL&gt; commit;

Commit complete.

SQL&gt; select * from dept@remotedb;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
        50 MARKETING      BOISE

SQL&gt; update dept@remotedb set loc = 'LONDON'
     where deptno = 50;

1 row updated.

SQL&gt; commit;

Commit complete.

SQL&gt; select * from dept@remotedb;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON
        50 MARKETING      LONDON

SQL&gt; delete from dept@remotedb
     where dname = 'MARKETING';

1 row deleted.

SQL&gt; commit;

Commit complete.

SQL&gt; select * from dept@remotedb;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   -->Note that DDL operations are not allowed through a database link:<br />
<!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<div id="textbox">
<div>
<pre class="large">SQL&gt; alter table dept@remotedb
     add column (manager varchar2(30));

alter table dept@remotedb add column
(manager varchar2(30))
                 *
ERROR at line 1:
ORA-02021: DDL operations are not allowed
           on a remote database</pre>
</div>
</div>
<p><!-- ccccccccccccccccccccccccccccccccccccccccccccccccc   --></p>
<h3>Recommended reading:</h3>
<div id="content">
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14231%2Fds_admin.htm%23i1007820&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fuse_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1007820" target="_blank">Oracle Online Documentation : Administrator&#8217;s Guide, Creating Database Links</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14200%2Fstatements_5005.htm%23SQLRF01205&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fuse_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#SQLRF01205" target="_blank">Oracle Online Documentation : SQL Reference, Create Datatabase Link syntax</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fasktom.oracle.com%2Fpls%2Fasktom%2Ff%3Fp%3D100%3A11%3A0%3A%3A%3A%3AP11_QUESTION_ID%3A393468893370&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fuse_oracle_database_link.html'); return false;" href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:393468893370" target="_blank">AskTom page with interesting troubleshooting tips for when you use oracle database links.</a></li>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/use-database-links/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Oracle database link</title>
		<link>http://oracle-database-tips.com/wp/dblinks/create-oracle-database-link</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/create-oracle-database-link#comments</comments>
		<pubDate>Fri, 23 Oct 2009 11:59:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[create oracle db link]]></category>
		<category><![CDATA[database users]]></category>
		<category><![CDATA[global name]]></category>
		<category><![CDATA[global names]]></category>
		<category><![CDATA[security risk]]></category>
		<category><![CDATA[word public]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=110</guid>
		<description><![CDATA[Syntax and explanation on creating Oracle database links.]]></description>
			<content:encoded><![CDATA[<p>Syntax :</p>
<p>CREATE {PUBLIC} DATABASE LINK<br />
{CONNECT TO<br />
IDENTIFIED BY  }<br />
USING &#8216;  &#8216;;</p>
<p>Privileges needed</p>
<p>When creating an oracle database link, you can decide to create it privately,<br />
for use only by the owner of the database link,<br />
or publicly, for use by all other database users who have the right privileges.</p>
<p>If you do not specify the word &#8216;PUBLIC&#8217; in the create statement, the database link will be created as a private one by default.<br />
Once a public database link has been created, it will be owned by a special user named &#8216;PUBLIC&#8217;.</p>
<p>The second decision is to create it with a hard-coded username and password, or without access credentials.<br />
If you create a public database link without access credentials, any user accessing it will do so with his own username and password.</p>
<p>Take care when creating a public dblink with a hardcoded username and password, it is a security risk.</p>
<p>Creation</p>
<p>Now that you are ready to create it, you must provide a database link name<br />
(this is what your db link will be called).</p>
<p>One common problem with dblinks is that Oracle will not allow you to create a db link whose name is different from the global name<br />
of the remote database if the local database&#8217;s &#8216;GLOBAL_NAMES&#8217; initialization parameter is set to &#8216;TRUE&#8217;.</p>
<p>Lastly, you must specify a valid tnsnames alias which Oracle will use to connect to the remote database.<br />
To test if your tnsnames.ora alias is valid, try to access it through sql*plus on your local server.</p>
<p>To be able to create a database link, you will need to have the system privilege<br />
&#8216;CREATE DATABASE LINK&#8217;<br />
or<br />
&#8216;CREATE PUBLIC DATABASE LINK&#8217;<br />
granted to you.</p>
<p>The remote user will need to have at least &#8216;CREATE SESSION&#8217; privileges.</p>
<p>Examples:<br />
Let&#8217;s create a private database link using a hard-coded username and password.</p>
<p>SQL&gt;Create database link remotedb connect to scott identified by tiger using &#8216;remotedb.world.com&#8217;;<br />
Database link created.</p>
<p>The same db link without a username/password:</p>
<p>SQL&gt;create database link remotedb using &#8216;remotedb.world.com&#8217;;<br />
Database link created.</p>
<p>Here&#8217;s an example to create a public database link with a username and password:</p>
<p>SQL&gt; create public database link remotedb connect to scott identified by tiger using &#8216;remotedb.world.com&#8217;;<br />
Database link created.</p>
<p>Here&#8217;s a public database link without a username and password.</p>
<p>SQL&gt;create public database link remotedb using &#8216;remotedb.world.com&#8217;;<br />
Database link created.</p>
<p>Recommended reading:</p>
<div id="content">
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14231%2Fds_admin.htm%23i1007820&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fcreate_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1007820" target="_blank">Oracle Administrator&#8217;s Guide: Create oracle database link</a></li>
<li><a title="opens new window" onclick="window.open('http://www.oracle-database-tips.com/cgi-bin/counter.pl?url=http%3A%2F%2Fdownload.oracle.com%2Fdocs%2Fcd%2FB19306_01%2Fserver.102%2Fb14200%2Fstatements_5005.htm%23SQLRF01205&amp;referrer=http%3A%2F%2Fwww.oracle-database-tips.com%2Fcreate_oracle_database_link.html'); return false;" href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5005.htm#SQLRF01205" target="_blank">SQL Reference: Oracle create database link syntax</a></li>
</div>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/create-oracle-database-link/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle Database Links Background</title>
		<link>http://oracle-database-tips.com/wp/dblinks/oracle-database-links-background</link>
		<comments>http://oracle-database-tips.com/wp/dblinks/oracle-database-links-background#comments</comments>
		<pubDate>Fri, 23 Oct 2009 02:55:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DB Links]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[correct privileges]]></category>
		<category><![CDATA[database server]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[oracle database link]]></category>
		<category><![CDATA[query data]]></category>

		<guid isPermaLink="false">http://oracle-database-tips.com/wp/?p=107</guid>
		<description><![CDATA[Oracle Database Links Background information]]></description>
			<content:encoded><![CDATA[<p><ins style="border: medium none; margin: 0pt; padding: 0pt; display: inline-table; height: 250px; position: relative; visibility: visible; width: 250px;"><ins style="border: medium none; margin: 0pt; padding: 0pt; display: block; height: 250px; position: relative; visibility: visible; width: 250px;"></ins></ins> <script type="text/javascript"><!--
&lt;! 
google_ad_client = "pub-7851621922754096";
/* 250x250left */
google_ad_slot = "5892931358";
google_ad_width = 250;
google_ad_height = 250;
// &gt;
// --></script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script><script type="text/javascript"><!--
google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);
// --></script><ins style="border: medium none; margin: 0pt; padding: 0pt; display: inline-table; height: 250px; position: relative; visibility: visible; width: 250px;"><ins style="border: medium none; margin: 0pt; padding: 0pt; display: block; height: 250px; position: relative; visibility: visible; width: 250px;"></ins></ins> <!-- ============================================================================================================================================================ --> A Database Link allows you to access data in a remote database as if it          is a local table&#8217;s data.</p>
<p>The connection can be made to a database hosted on the same machine or          remotely on another server.</p>
<p>When you query data on a different database, you are essentially using          a distributed query.<br />
It is also possible to execute distributed transactions through database          links like insert, update and delete.</p>
<p>The authentication used in a database link is either the link&#8217;s owner          or a hard-coded username and password, depending on the way the link was          created.</p>
<p>A database link in oracle can be either private (for use only by the link&#8217;s          owner) or public (accessible to any user with the correct privileges).</p>
<p>Connectivity is established via Sql*Net, using an alias defined in the          local database server&#8217;s tnsnames.ora</p>
<p>Have a look at the tutorials on this site  to find out more about oracle database          links :</p>
<p><a href="http://oracle-database-tips.com/wp/category/dblinks">Dblinks category</a></p>
]]></content:encoded>
			<wfw:commentRss>http://oracle-database-tips.com/wp/dblinks/oracle-database-links-background/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

