Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Separation of SQL Learning and additional Database

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. To separate a database is to delete a database from the list of SQL Server databases so that it is no longer managed and used by SQL Server, but the files (.MDF) and corresponding log files (.LDF) of the database are intact. After the separation is successful, we can copy the database file (.MDF) and the corresponding log file (.LDF) to other disks for backup. Right-click the student database, the effect is as shown in the picture

2. Attach a database, that is, copy the database file (.MDF) and the corresponding log file (.LDF) from a backup disk to the computer you need, and add them to a SQL Server database server, which manages and uses the database.

1) right-click the database node, pop up the shortcut menu, and select the "attach" command.

2) the [attach Database] dialog box appears, click the "add" button, and the "locate Database File" dialog box appears. In this dialog box, only the data files of the database, namely "mdf" files, are displayed by default. The effect is shown in the picture (because there is something wrong with my database, this option is not attached. I made the following two pictures on other computers)

Finally, what is the role of separating and attaching databases?

1. You can cut off the use of the database (for example, when the database log takes up a lot of space, you can cut off the database by separating the database, thus deleting the previous database log to save space)

2. It can be used when the physical storage address of the database needs to be changed. If your database system is installed on a system disk (such as C disk), because C disk is vulnerable to viruses, you may want to store your data on a non-system disk (such as D disk). This is simple, you do not need to reinstall the database, just "detach" the data, then move the relevant files to a directory on disk D, and then "attach" the database.

Note that the database can be detached only if the number of connections using this database is 0. So when separating the database, try to disconnect all connections to the operation of the database to be detached. If there is a program that connects to the database, the connection status window of the database will appear, showing the machine and the name of the machine that is connecting to the database. Click the clear button to force disconnect the existing connection from the server.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report