SQL Server changes the Database Name and logical file name

Source: Internet
Author: User
Today, when I backed up a database and restored it to another database, I found that it could not be restored. I looked at the inconsistency between the logical File Name of the original database and the physical file name. The following method can be used to change the file name.
In the Enterprise Manager of SQL Server, it seems that you cannot directly change the database name. If you want to change the name, it is most convenient to run in the query Analyzer:
Alter database original database name
Modify name = new database name

In SQL Server, the physical file name can be changed during database restoration, or the database can be separated, and the MDF file name can be changed and appended directly. However, changing the logical file name does not seem so intuitive.

Run in the query Analyzer:
Alter database name
Modify file (name = original logical file name, newname = new logical file name)

In this way, you can change the logical file name. Because SQL Server has data files and log files, you must change the logical file names of both data files and log files, write two statements similar to the preceding statement.

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.