Q
Problem solve Get help with specific problems with your technologies, process and projects.

Updating two different databases with the SQL UPDATE method

How do I update two different databases located at two different locations using the SQL UPDATE method?

What you are trying to do is called a Distributed Transaction. Part VI of the Oracle 9i Administrator's Guide (http://technet.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96521/toc.htm) discusses this topic in much detail.

The basic idea is to create a database link from one database to another. You do this as follows:

CREATE DATABASE LINK remote_db CONNECT TO user
IDENTIFIED BY pswd USING 'tns_alias';
This link tells which system to connect to (tns_alias), which userid in that system (user) and that user's password (pswd). Now that the link is set up, we can access any table in that remote database that the user has permissions to by using the '@link_name' clause on the table name. So to answer your question, we can update a table in another database with a query similar to the following:
UPDATE some_table@remote_db SET colA='some_value'
WHERE colB='some_other_value';

For More Information


This was last published in October 2002

Dig Deeper on Oracle database design and architecture

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close