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

What's the difference between separating a database and attaching a database?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

What's the difference between separating a database and attaching a database? Many people do not understand, today, in order to make you better understand the separation of databases and additional databases, so give you a summary of the following content, let's look down together.

SQL Server provides a variety of database backup and recovery methods, such as "detach / attach" database, "backup / restore" database, replication database and so on.

The detach / attach method copies the database file (.MDF) and the corresponding log file (.LDF) to other disks for backup, and then copies the two files to any system that needs the database.

1. To separate a database is to delete a database (such as student_Mis) 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.

2. The attached database is to copy the database file (.MDF) and the corresponding log file (.LDF) from a backup disk to the desired computer, and add them to a SQL Server database server "target=" _ blank "href=" http://undefined"> server, which manages and uses the database.

Process steps:

one。 Detach database

1. After starting SSMS and connecting to the database server, expand the server node in object Explorer. Find the database name that needs to be separated under the database object. Here, take the AppCtrl database as an example. Right-click the AppCtrl database and select Properties from the pop-up shortcut menu.

two。 Select the options object in the area below the selection page on the left side of the database properties window, then find the status item in the other options list in the right area, click the restrict access text box, and select SINGLE_USER in its drop-down list.

3. After clicking the OK button in the image above, a message box appears informing us that this operation will close all connections to the database and whether to continue the operation (as shown in the following figure). Note: in a large database system, it is a dangerous action to disconnect other connections to the database at will, because we do not know what the application connected to the database is doing. perhaps what is being disconnected is a transaction that is in a complex update operation to the data and has been running for a long time.

4. After you click the Yes button, add "single user" after the database name (as shown in the following figure). Right-click the database name and select the secondary menu item "detach" of tasks from the shortcut menu. The detach Database window shown in the following figure appears.

The names of the databases we want to detach are listed in the detached database window in the following figure. Please select the Update Statistics check box. If there is no active connection in the message column, the status column is displayed as ready; otherwise, not ready is displayed, and you must check the check box in the Delete connection column.

5. When the detach database parameters are set, click OK at the bottom to complete the detach operation for the selected database. At this point, the database name AppCtrl that has just been separated will not be seen in the list of database objects in object Explorer.

two。 Additional database

1. Copy the database and log files that need to be attached to a folder that has been created.

two。 In the following window, right-click the database object and select attach from the shortcut menu to open the attach database window.

3. Click the add button to add the suffix .MDF file.

4. Complete by default.

The above is a brief introduction to the difference between the separate database and the additional database, of course, the detailed use of the above differences have to be used by everyone to understand. If you want to know more, welcome to follow the industry information channel!

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