Get the App
SLTechnology News&Howtos  ›  Database  › 

SQL detach database

Shulou Source: shulou.com Published: 2022-06-01 08:21:42 10月01日 Update

Separate data

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 student_Mis database as an example. Right-click the student_Mis database and select Properties from the pop-up shortcut menu.

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.

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.

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 appears as shown in the following figure

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.

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 student_Mis that has just been separated will not be seen in the list of database objects in object Explorer (as shown in the following figure). So we can separate.

Tags: Data database name object selection button menu zone property server in progress message status resource resource management check box update service management complexity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn Shulou Tech Info Xiaomi Redmi