SQL Server复制功能要避开缺陷的干扰小结
SQL Server具有强大的复制功能,除了将数据和数据库对象从一个数据库复制并准确分发的另一个数据库中,还要实行数据库之间的同步。
SQL Server的复制分为三种,下面介绍一下这三种复制技术及其存在的一些缺陷,大家在使用时可以根据具体的情境选择适用的复制方法,避开这些缺陷的干扰。1. 快照复制
A每隔一段时间将B中的相应表中的数据全部删除,然后将自己相应表中的全部插到B中。此种方式显然不适合我们的应用,不予考虑。
2. 事务复制
对A中的每一个满足复制条件的事务,每隔一定时间A都应用到B上,反之亦然。SQL Server 通过把数据传给三个存储过程(插入,删除,修改)进行数据的修改,我们可以根据自己的应用改写此存储过程。
存在缺陷:如果从A到B的复制条件和从B到A复制条件相同的话,会产生“踢皮球”的循环现象。既一系列事务应用于A,A会把这些事务应用于B,B收到这一系列事务后,又会把它应用于A,……如此循环。
3. 合并复制
每隔一段时间,复制将会把数据库A,B中需要复制的数据合并一下,使得AB中的数据完全一样,数据都是AB数据库中数据的全体数据。如果A和B中数据主键有冲突,则根据优先级只选其中一条数据。
需要注意:为了区分数据来自于哪个地点,SQL Server会将每一个需要复制的表中另加一个字段,在编程时应该注意。
存在缺陷:
SQL Server 每隔一定时间进行一次复制,如果找不到另一台Server(比如因为网络故障,或是另一台SQL Server没有启动),经过n(默认为10)次连接后,它的复制功能将会down掉,直至有人将复制功能启动。 需要复制的表中如果在复制之前就有数据,在建立复制时比较麻烦(SQL Server不提供此类问题的解决方法,需要手动完成)。因此,需要复制的表在使用过程中不能经常变动表结构。(文/张梦强)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The import steps are as follows: Copy the MDF file to SQL Server's data directory (usually C:\Program Files\Microsoft SQL Server\MSSQL\DATA). In SQL Server Management Studio (SSMS), open the database and select Attach. Click the Add button and select the MDF file. Confirm the database name and click the OK button.

For objects with the same name that already exist in the SQL Server database, the following steps need to be taken: Confirm the object type (table, view, stored procedure). IF NOT EXISTS can be used to skip creation if the object is empty. If the object has data, use a different name or modify the structure. Use DROP to delete existing objects (use caution, backup recommended). Check for schema changes to make sure there are no references to deleted or renamed objects.

When the SQL Server service fails to start, here are some steps to resolve: Check the error log to determine the root cause. Make sure the service account has permission to start the service. Check whether dependency services are running. Disable antivirus software. Repair SQL Server installation. If the repair does not work, reinstall SQL Server.

To view the SQL Server port number: Open SSMS and connect to the server. Find the server name in Object Explorer, right-click it and select Properties. In the Connection tab, view the TCP Port field.

If you accidentally delete a SQL Server database, you can take the following steps to recover: stop database activity; back up log files; check database logs; recovery options: restore from backup; restore from transaction log; use DBCC CHECKDB; use third-party tools. Please back up your database regularly and enable transaction logging to prevent data loss.

SQL Server database files are usually stored in the following default location: Windows: C:\Program Files\Microsoft SQL Server\MSSQL\DATALinux: /var/opt/mssql/data The database file location can be customized by modifying the database file path setting.

The problem was found that this time I was using the SqlServer database, which I had not used before, but the problem was not serious. After I connected the SqlServer according to the steps in the requirements document, I started the SpringBoot project and found an error, as follows: At first I thought it was a SqlServer connection. There was a problem, so I went to check the database and found that everything was normal. I first asked my colleagues if they had such a problem, and found that they did not, so I started my best part, facing Baidu. programming. The specific error message I started to solve was this, so I started Baidu error reporting: ERRORc.a.d.p.DruidDataSource$CreateCo

If the SQL Server installation fails, you can clean it up by following these steps: Uninstall SQL Server Delete registry keys Delete files and folders Restart the computer
