Create a new database accounting with the default configuration
Use master;
Go
Create Database accounting;
Go
Method 1: select database> F2 from the object Resource Manager on Microsoft SQL Server Management Studio (SSMs), or right-click Database> rename image 1. Method 2: write SQL statements
Use master;
Go
Exec sp_renamedb n 'accounting', N 'financial ';
Go
However, we opened the default storage path of the database and found that the names of MDF and LDF have not changed.
Figure 2
You may want to detach the database and rename the financial. MDF, financial_log.ldf, and reattach the database directly to the data files and log files.
Figure 3
"An error occurred while attaching the database." How can this problem be solved?
Click the message to view the error details.
Figure 4
Unable to open the physical file accounting. MDF description after renaming, the database does not recognize the name we changed.
By viewing the "Financial" database details, we found that the content of the current file path field is incorrect, and the message field also showed that the file could not be found.
Therefore, we make the following changes:
Click OK. The database is attached!