Home > Ask the Oracle Database / Applications Experts > Oracle database backup and recovery Questions & Answers > Updating data in remote database when local database is updated
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Updating data in remote database when local database is updated

Brian Peasland EXPERT RESPONSE FROM: Brian Peasland

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 12 November 2004
I do not know how to update the database remotely while I am entering data on another remote area of the database. In short, there two databases, one with Oracle 8i and one with Oracle 9i, at two different locations. At one location, one person enters data through the SQL form. The database at the other location, which is remote, should be automatically updated with the same record. Please give me details that I can understand easily.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Oracle database backup and recovery
How to export triggers in an Oracle export command
How to precreate Oracle table extents and define extent size
How to trim the Oracle listener log in Unix/Linux
How to avoid invalid objects in Oracle when restoring the database
How to perform an Oracle 9i upgrade with the Database Upgrade Assistant
How to avoid Oracle error ORA-00060 when dropping a datafile in Oracle 10g
How to precreate tablespaces in Oracle before a new database import
How to solve an Oracle import error
How to use Transportable Tablespaces in Oracle to copy files quickly
How to use Oracle table extents to allocate less disk space

Oracle database backup and recovery
How to export triggers in an Oracle export command
How to precreate Oracle table extents and define extent size
How to trim the Oracle listener log in Unix/Linux
How to avoid invalid objects in Oracle when restoring the database
How to perform an Oracle 9i upgrade with the Database Upgrade Assistant
How to avoid Oracle error ORA-00060 when dropping a datafile in Oracle 10g
How to precreate tablespaces in Oracle before a new database import
How to use Transportable Tablespaces in Oracle to copy files quickly
How to solve an Oracle import error
Exadata: A first look at Oracle's entry into the appliance market
Oracle database backup and recovery Research

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


The first thing you need to do is to create a database link pointing to the other location. The database link can be created with a command similar to the following:

CREATE DATABASE LINK other_db CONNECT TO scott IDENTIFIED BY tiger
USING 'tns_alias';

You'll want to give the database link a better name, use the appropriate userid/password to connect to the remote database, and configure your TNSNAMES.ORA file with a TNS alias to point to that database. You can test the database link with a simple query like the following:

SELECT sysdate FROM dual@other_db;

The "@other_db" clause uses the database link you created. If the query returns the date, then the link works properly. Once the link is set up, you can either issue a command to modify the data in the remote database when you modify the local database, or you can use a database trigger. For instance, if the application modifies the local database by performing an INSERT similar to the following,

INSERT INTO my_table VALUES (1,'Two');

then you can also code another SQL statement to insert the same values across a database link.

INSERT INTO my_table@other_db VALUES (1,'Two');

Additionally, you can create a trigger:

CREATE TRIGGER modify_remote_my_table
BEFORE INSERT ON my_table
BEGIN
  INSERT INTO my_table@other_db VALUES(:new.colA, :new.colB);
END;
/

You can write similar triggers for updating and deleting rows as well.




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts