We can only do the point in time recovery under Full or Bulk insert mode.
- -- Setup the test ENV
- ALTER DATABASE AdventureWorks2008R2 SET RECOVERY FULL;
- -- Backup the database
- BACKUP DATABASE [AdventureWorks_new] TO DISK ='C:\dump\AdventureWorks_new_20111029.db' with format
- -- Create The test Table
- CREATE TABLE TB_1
- (number INT IDENTITY(1,1) NOT NULL,
- name varchar(50) NOT NULL,
- updateTIme datetime default getdate(),
- )
- --- Insert Test data
- DECLARE @count INT
- SET @count = 0
- WHILE (@count < 40)
- BEGIN
- Insert into TB_1 (name)values('SUMMER')
- -- wait for 10 second
- WAITFOR DELAY '00:00:10'
- SET @count = (@count + 1)
- END
- -- BACKUP TRAN LOG
- BACKUP LOG [AdventureWorks_new] TO DISK ='C:\dump\tran\AdventureWorks_new.1.log' with format
- -- Slect the data
- select * from TB_1 where TB_1.number = 5;
- -- Delete Data
- delete TB_1 where TB_1.number =5;
The row number 5 is gone after line 28 delete statement. Lets try to restore it.
First, we take another tran log backup
- -- BACKUP TRAN LOG
- BACKUP LOG [AdventureWorks_new] TODISK ='C:\dump\tran\AdventureWorks_new.2.log' with format;
Then, lets restore with below orders:
- Full backup with no recovery
- Tran log 1 with no recovery and time stamp
- Tran log 2 with no recovery and time stamp
- -- Restore the FULL DB BACKUP with norecovery
- -- KIll all the connection and start the restore
- use master;
- RESTORE DATABASE [AdventureWorks_new] fromDisk ='C:\dump\AdventureWorks_new_20111029.db' with NORECOVERY;
Since it is NORECOVERY, the database shows as Restoring…
- -- Restore the 1 tran dump with norecovery
- RESTORE LOG [AdventureWorks_new] from Disk = 'C:\dump\tran\AdventureWorks_new.1.log'
- with NORECOVERY , STOPAT = '2011-10-28 22:32:01.133';
- -- Restore the 2 tran dump till the time it is being deleted and
- RESTORE LOG [AdventureWorks_new] from Disk = 'C:\dump\tran\AdventureWorks_new.2.log'
- with NORECOVERY , STOPAT = '2011-10-28 22:32:01.133';
- --- RESTORE DB
- RESTORE DATABASE [AdventureWorks_new] WITH RECOVERY;
STOPAT must follow by the time stamp where you want SQL Server stop applying the transaction log. Any log before that time (Including that time will not apply to the database)
In the production environment , if row being delete by accidently, it may not be a good idea to do this type of restore. As the database is not available during the time of restore. Most importantly, you will take a risk what if restore fail and you are losing the entire db. It is the best you can restore the database in the test environment and recover from there.
ReplyDeleteHiện tại Nhạc Thành đã gặp được Lê Giang Nam, Nam Cung Hiên và nhóm người lão bà áo tím cho nên phải cất tiếng chào hỏi.
- Ta còn tưởng rằng U Minh tông và Luyện Dược sư công hội đám người đã đến đây hóa ra lại là ngươi.
Lê Giang Nam mỉm cười nói.
Ma lúc này ở Tuyệt Tình cốc, Vạn Kim Môn Cuồng Sư môn ba thái thượng trưởng lão đều đánh giá Nhạc Thành.
Một lát sau Nhạc Thành cùng với đám người Lê Giang Nam, Nam Cung Hiên tới đại sảnh thương nghị giáp mặt chúng nữ.
dongtam
mu moi ra hom nay
tim phong tro
http://nhatroso.com/
nhạc sàn
tổng đài tư vấn luật
văn phòng luật hà nội
tổng đài tư vấn luật
thành lập công ty trọn gói
http://we-cooking.com/
chém gió
trung tâm tiếng anh
Về phần Hỏa Lão, lão cũng tiến tới bên cạnh Nhạc Thành, lão già áo đỏ trong Tuyệt Tình cốc cũng đánh giá Hỏa Lão, bà tựa hồ như là hiểu biết nhưng không xác định được đó là ai.
Ở trong đại sảnh, mọi người phân ra mà ngồi, sau khi ngồi vào chỗ của mình, Nhạc Thành nói cho mọi người biết chuyện xảy ra bảy ngày trước ở Hồ Điệp cốc.
- Nhạc Thành, ngươi nói là ngươi giết U Minh Thánh, Hồng Ma và Thanh
OMEGA buy replica watches has been a world leader in advanced watch design replica omega since 1848. Over the years, the brand has been widely celebrated for their durability and precision. OMEGA has served as the official timekeepers of the Olympic Games for nearly a century. They also created the official watch of the space program and first watch to land on the moon. Buying an OMEGA watch is an excellent way to invest in a piece of history.
ReplyDelete