Home > Ask the Oracle Experts > 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.

>
EXPERT RESPONSE

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.


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


RELATED CONTENT
Database Backup and Recovery
ORA-27101 error: shared memory realm does not exist
How to set up a job for an SQL query in Oracle 10g Grid Control
Hot backup when Oracle Database is up
ORA-06550 error when exporting a database
Why do I have to start my Oracle database manually?
How to recover a control file
The USING BACKUP CONTROLFILE clause in Oracle commands
Backup and recoveries of Oracle RAC 10gR2
How to use the OPatch Utility in Oracle
Backup and recovery of Oracle 10g with forgotten admin password

Oracle database backup and recovery
Oracle 11g: Backup and recovery concepts
Weighing remote database administration pros and cons takes care
Data retention policy for Oracle DBAs: When to "trash" your data
Case study: Oracle RMAN improves backup and recovery efficiency in a multi-platform, multi-application environment
How do I do that in Oracle?
Oracle and the rise of the virtual machine
Oracle 11g data compression
Oracle OpenWorld 2007 Special Report
Hierarchical storage management for database growth, part 1
One datafile not accessible
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



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

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

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




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