This article mainly summarizes the processing method of identifying columns in replication
1. Snapshot Copy In snapshot replication, there is usually no need to consider the properties of the identity column.
2, transaction replication example: release database A, subscribe to database B, publication is t_test_a, subscription table is t_test_b create table t_test_a (id int identity (1, 1), name varchar (50)) Create Table T_test_b (ID IdenT " 1, 1), Name VARCHAR (50)) In this case, the replication agent will not copy the new line to the library B, because the column ID is the identity column, cannot give the identity column to provide a value, and the copy fails. At this time, you need to set the Not for Replication option for the identity column. Thus, when the replication agent is connected to the table t_test on the library B with any login, all NOT for Replication options on the table will be activated and the ID column can be explicitly inserted.
Here are two cases: 1. The T_TEST table of library B will not be updated by the user (or application): if the T_test of the library B is not updated by the user (or application), then it is recommended to remove the ID column Identification attribute, only using a simple int type.
2. The T_Test table of library b is updated by other users (or applications)
In this case, the ID columns of the two T_test tables have conflicts, for example, executing the following statement in the library A: INSERT TOME (Hypothesis is listed as 1) In the library B The following statement: INSERT T_TEST_B (NAME) VALUES (hypothesis is 1) This will insert a record in the two tables of the library A and library B, obviously two different records. However, things have not ended yet, and the pre-set copy time, the replication agent attempts to put the record "1 TOM" into the T_test table in the library B, but the t_test_b table of library B already exists
The number of ID is 1, insertion is not successful, through copying the monitor, we will find that the copy failed. Methods to solve the above problems include: (1) Specify different ranges for the publisher and subscribers, if the above example can be modified: , 1), Name Varchar (50)) Create Table T_test_b (ID IdenTentity (10)), Name Varchar (50)) (2) Do not repeat the value of the publisher and subscriber's identity column, such as Use odd value crete Table t_test_a (id int identity (1, 2), name varchar (50)) - uses even value crete Table T_test_b (ID ID IDENTITY (2, 2), Name Varchar (50)) This method can Promote, when the booking party and the publisher have four, the definition of the identity column attribute is as follows (1, 4), (2, 4), (3, 4), (4, 4)
3. Merging replication uses transaction replication solutions, as long as the value of the publishing table and the subscription list is not either.