Database separation refers to the separation of databases from the server.
When the SQL server is running, it maintains information about all databases, including the databases that are currently not used. If these databases are not used for the time being, running them will only increase the burden on the server, so we need to separate these databases that are not used for the time being.
Implementation of database separation:
Right-click the database you want to detach and select the "detach Database" option in the "all tasks" list:
The following dialog box is displayed:
The status of the selected database is displayed. In "database status", "connection using this database" is 0, indicating that this database is not currently in use, if you do not manage the database for the time being, you can separate it.
You can select "separation options" based on your needs.
Click OK:
The database is detached successfully.
In another case, if the database to be detached is in use, the following dialog box will pop up when performing the above operation:
In "database status", "Use the connection of this database" is 1. Different from the above, it indicates that a connection is currently in use for this database.
If you want to detach the database, click "clear" to bring up the following dialog box:
Click OK. A prompt dialog box is displayed:
If yes is selected, the server sends a message to the user who uses the database to remind the user that the current database is to be stopped. Otherwise, the user is not notified, the preceding dialog box is in the following status:
The number of connections is 0. We need to wait for the user to stop using the database before selecting the "OK" button to detach the database. Otherwise, if the user does not stop using the database, we click "OK", the following error Prompt window will pop up:
If you do not stop the server, we only have to wait for the user to respond.
Only when the user stops using the database to be detached can the database be detached.
After the database is detached, the database is not displayed on the console ,:
Obviously. Our teacher database is separated and the server no longer manages its information.
Additional database
Attaching a database refers to re-adding the detached database to the server.
Implementation of attaching a database:
Right-click the "Database" in the "Enterprise Manager" directory tree window, and select the "Additional database" option in the "all tasks" list:
The following window is displayed:
Click Browse (the one before the "verify" button ):
You can find the database you want to attach in the local disk directory (usually under the Microsoft SQL Server/MSSQL/Data Directory:
Click OK:
The attached database is successfully attached. You can view the attached database in the window on the right of the console.