Use a new name to restore the database

Source: Internet
Author: User
Tags log backup

Database recovery can be achieved by using a new name, which often meets the needs of the business. When you use a different name to restore the database, you will have to set up a new location for each file in the database. If you have not previously known what files are in the database, you can run the RESTORE FILELISTONLY declaration to obtain the number and name of the database files. Running restore FILELISTONLY can provide you with information about the file, such as the logical name of the file, the physical name, whether the file is a data file or a log file.
Next, execute the RESTORE database declaration, including a new name for the database, and a backup of the files that will be stored. If you want to process log files, use NORECOVERY.

In the following example, we will create a database called Mynwind2_test, which is a copy of MyNwind2, MyNwind2 file contains two files Mynwind2_data and Mynwind2_log. As MyNwind2 already exists, Mynwind2_data and Mynwind2_log will be transferred to another place.

Use master
Go

You can now determine the number and name of files in a file backup.

RESTORE filelistonly
From MyNwind2

Finally, you can restore the MyNwind2 file to the Mynwind2_test file

RESTORE DATABASE Mynwind2_test
From MyNwind2
With RECOVERY,
Move ' mynwind2_data ' to ' D:\MyData\MyNwind2_Test_data.mdf ',
Move ' mynwind2_log ' to ' D:\MyData\MyNwind2_Test_log.ldf '
Go



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.