SQL Server replication capabilities to avoid bug interruptions

Source: Internet
Author: User
Tags copy insert sql

SQL Server has powerful replication capabilities, in addition to synchronizing data and database objects from one database to another and accurately distributing them. SQL Server replication is divided into three kinds, the following describes the three kinds of replication technology and some of the deficiencies, we can use the specific circumstances to choose the appropriate replication methods to avoid these defects interference.

1. Snapshot replication

A you remove all the data from the corresponding table in B at intervals, and then insert all of your corresponding tables into B. This approach is clearly not suitable for our application and is not considered.

2. Transactional replication

Every time a transaction that satisfies a replication condition in a is applied to B, and vice versa. SQL Server modifies the data by passing it to three stored procedures (INSERT, delete, modify), and we can overwrite the stored procedure according to our own application.

Defect: If the copy condition from A to B is the same as the copy from B to A, the "buck" loop phenomenon is generated. A series of transactions applied to A,a will apply these transactions to the b,b after receiving the series of transactions, and applying it to a, ... So loop.

3. Merge replication

Every once in a while, replication will merge the data that needs to be replicated in the database a,b so that the data in AB is exactly the same, and the data is all the data in the AB database. If there is a conflict between the data primary keys in A and B, only one of the data is selected based on priority.

Note: To differentiate where the data comes from,SQL Server adds a field to each table that needs to be replicated, which should be noted when programming.

There are defects:

SQL The server replicates at a certain time, and if no other server is found (for example, because of a network failure or another SQL server does not start), its replication functionality will be down after the N (default 10) Secondary connection, Until someone starts the replication feature. In tables that need to be replicated, if there is data before replication, it can be cumbersome to build replication (SQL Server does not provide a workaround for this type of problem and needs to be done manually). Therefore, tables that need to be replicated cannot change the table structure frequently during use. (Text/Zhangmengiang)



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.