Table Replication Using Materialized View in Oracle 11g
Table Replication Using Materialized View in Oracle 11g
Source Database:prim
Target Database:-stand
Step 1.create the USERS table and add some sample records inside.
At source database:-
[oracle@server1 ~]$ sqlplus sys/system as sysdba@prim
SQL> create user appuser identified by appuser;
SQL> GRANT CONNECT,RESOURCE TO appuser;
SQL> conn appuser/appuser
Connected.
At target database:-
Step 2.Now before creating database link we need to add entry inside tnsnames.ora file
so that the target database can connect to the source database.
prim =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = server1.soumya.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PRIM)
)
)
:wq
so we added the tnsentry for source database i.e. prim inside tnsnames.ora file
Step 3.Now connect to the local database i.e. target and create a user appuser2
At target database:-
Step 3.Now create a database link to connect source database from appuser2
[oracle@server2 ~]$ sqlplus appuser2/appuser2@stand
SQL> CREATE DATABASE LINK stand CONNECT TO appuser IDENTIFIED BY appuser
USING 'prim';
CREATE DATABASE LINK stand CONNECT TO appuser IDENTIFIED BY appuser USING
'prim'
*
ERROR at line 1:
ORA-02082: a loopback database link must have a connection qualifier
While creating the database link i was facing the above error and i fixed it using the below steps
SQL>select * from global_name;
STAND
-- write down the current name;
Now You must be able to Select any table from user APP1 On Source Database from target
database.
At target database:-
[oracle@server2 ~]$ sqlplus appuser/appuser@prim
SQL> select * from users;
At source database:-
SQL> conn appuser/appuser
SQL> INSERT INTO USERS VALUES (4, 'ROBERT', 'ASPRIN', 'PASS4')