Previous | Table of Contents | Next |
This column group is now called MYGROUP as specified for the third parameter. If later we want to add another column, this is not difficult: just another call to a PL/SQL procedure. In this next example, we are adding a column called cash_back; it obviously must exist in our Sales table.
DBMS_REPCAT.ADD_GROUPED_COLUMN(SALES, SALES, MYGROUP, cash_back);
We can also remove a name from a column group by using the following command to remove the column unit_price from the group:
DBMS_REPCAT.DROP_GROUPED_COLUMN(SALES,SALES,MYGROUP, unit_price);
To drop this complete column group that we have created, we call another package:
DBMS_REPCAT.DROP_COLUMN_GROUP(SALES,SALES,MYGROUP);
Above we defined the three major conflicts of replication; Oracle has created three procedures to handle the three scenarios of update, uniqueness, and delete conflicts. The three procedures in the DBMS_REPCAT package to define conflict resolution routines are respectively named ADD_UPDATE_RESOLUTION, ADD_UNIQUE_RESOLUTION, and ADD_DELETE_RESOLUTION. They also exist as internal triggers with version 8 that give the user more security against unwanted changes to them.
For instance, say that we want to make sure that the latest prices and unit sales figures are entered into the system, we would use our column_group MYGROUP in the following PL/SQL replication call:
DBMBS_REPCAT.ADD_UPDATE_RESOLUTION ( SALES, /* Table Owner */ SALES, /* Table Name */ MYGROUP, /* Column Group */ 1, /* Sequence */ LATEST_TIMESTAMP, /* Update Method */ purchase_timestamp, /* parameter column name*/ NULL, /* priority group */ NULL, /* function name */ the latest purchase timestamp will decide the conflict /* comment */ );
In this case, we are instructing Oracles replication mechanism to resolve all update conflicts for the mentioned Column Group using the greatest timestamp on the column purchase_timestamp.
There are many other types of conflict resolution and the use of priority levels for a column_group. We will not go into all these variations. The basic principle of setting up these different conflict resolution strategies through calls to the package DBMS_REPCAT remains the same or through Oracles replication manager remains the same.
One major benefit of Oracles strategy in using PL/SQL as the foundation of replication is that this enables the user to create customized conflict resolution logic. Logic such as this can be in the form of a user-defined PL/SQL function that returns a Boolean value, TRUE or FALSE. Here a more complex strategy can be defined using the PL/SQL language. This might be useful because the default resolution strategies might not be adequate for your replicated environment.
One of the attractions of replication is survivability. This refers to the capability of the distributed database to remain online with current data from even a site that has gone down.
For instance, if California fell into the sea and our fourth sales site, San Francisco, suddenly disappeared into the surf, we would still have all the data that had been refreshed from that site on any other master site. The only data that would be missing would be data that had been logged in San Francisco yet not transferred. Transactions that needed to send data from other sites to San Francisco could either be rolled back from the second phase of our two-phase commit, or these transactions could instead be accepted manually using the packaged PL/SQL or the Replication Manager.
Survivability can be easily obtained using Oracles Parallel Server. Never move into replication for this feature alone, unless your two database sites are physically separate. If you plan to create a highly available system, the Parallel Server is a better choice. If one node goes down on the parallel server, the server will fail-over without any lost transactions.
The drawback to the Parallel Server is that this configuration is characterized by many CPUs and/or operating system instances sharing the same disks. If your disks crash, you can have all the survivalist procedures in place yet you will not have access to your data or your database. In a replicated system, the hardware is totally physically separated, connected only by a network, so a hard-disk crash on one system will still not bring the system down and might only affect a few transactions.
Figure 16.12 shows the differences in architecture between survivability in a replicated environment and survivability in a parallel environment.
Figure 16.12. Because data and hardware are physically separated in remote replication, if one location fails, the system will survive.
If you do decide to use replication as a survivability tool, here are a few tips to remember when setting up your replication strategy:
Previous | Table of Contents | Next |