Wednesday, December 1, 2010

Replication of DB:


Database replication is the creation and maintenance of multiple copies of the same database. In most implementations of database replication, one database server maintains the master copy of the database and additional database servers maintain slave copies of the database. Database writes are sent to the master database server and are then replicated by the slave database servers. Database reads are divided among all of the database servers, which results in a large performance advantage due to load sharing. In addition, database replication can also improve availability because the slave database servers can be configured to take over the master role if the master database server becomes unavailable.

Database replication can be performed in at least three different ways:

  1. Snapshot replication: Data on one database server is plainly copied to another database server, or to another database on the same server.
  2. Merging replication: Data from two or more databases is combined into a single database.
  3. Transactional replication: Users obtain complete initial copies of the database and then obtain periodic updates as data changes.

Multi-master replication, where modifications can be tendered to any database server, and then flow through to further database servers, is frequently preferred. However, it establishes considerably bigger expenses and intricacy which may make it not viable in several circumstances. The universal dispute that exists in multi-master replication is transactional inconsistency avoidance or resolution. Most synchronous or keen replication systems do inconsistency avoidance, while asynchronous systems have to do inconsistency resolution. The resolution of such an inconsistency may be based on a timestamp of the transaction, on the ladder of the source servers or on much more intricate reason, which decides every time on all servers.

Database replication turns out to be complicated when it increases in size and magnitude. Typically, the increase relates with two dimensions; horizontal and vertical. Horizontal increase has extra data copies, vertical increase has data copies situated remotely. Troubles conceive by horizontal increase can be lessened by a multi-layer multi-view access protocol. Vertical increase is dashes into less trouble because internet dependability and performance are becoming better.

Tuesday, November 30, 2010

Attaching & Detaching

Detach:
USE master
GO
sp_detach_db 'ApressFinancial'

Attach:
CREATE DATABASE ApressFinancial
ON (FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\
Data\ApressFinancial.MDF')
FOR ATTACH