This article mainly summarizes the operation tips such as pending operations, shrinking databases, compressing databases, and transferring databases to new users with existing user permissions, checking backup sets, and restoring databases during installation.
1. suspend the operation
When installing the SQL or SP patch, the system prompts that a pending installation operation is required. Restart is often useless. solution:
Go to HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Session Manager to delete PendingFileRenameOperations.
2. shrink the database
Re-indexing:
DBCC REINDEXDBCC INDEXDEFRAG
|
Shrink data and logs:
DBCC SHRINKDBDBCC SHRINKFILE
|
3. compress the database
dbcc shrinkdatabase(dbname)
|
4. Transfer the database to a new user with the existing user permission
exec sp_change_users_login 'update_one','newname','oldname'go
|
5. Check the backup set
RESTORE VERIFYONLY from disk='E:\dvbbs.bak'
|
6. Restore the database
ALTER DATABASE [dvbbs] SET SINGLE_USERGODBCC CHECKDB('dvbbs',repair_allow_data_loss) WITH TABLOCKGOALTER DATABASE [dvbbs] SET MULTI_USERGO
|
CHECKDB has three parameters:
REPAIR_ALLOW_DATA_LOSS: executes all repairs completed by REPAIR_REBUILD, including allocating and unassigning rows and pages to correct allocation errors, structure row or page errors, and deleting corrupted text objects. These fixes may cause some data loss. The repair operation can be completed under the user transaction to allow the user to roll back the changes. If the rollback is fixed, the database will still contain errors and the backup should be restored. If an error fix is missing due to the severity of the severity level provided, it will omit any fix that depends on the fix. After the restoration, back up the database.
REPAIR_FAST Performs small and time-consuming repair operations, such as fixing additional keys in non-clustered indexes. These repairs can be completed quickly without the risk of data loss.
REPAIR_REBUILD executes all the repairs completed by REPAIR_FAST, including repairs that require a long period of time (such as re-indexing), so there is no risk of data loss when performing these repairs.
DBCC CHECKDB('dvbbs') with NO_INFOMSGS,PHYSICAL_ONLY。
|
[Content navigation] |
Page 1: SQL Server database practical operation tips |
Page 1: SQL Server database practical operation tips |
Page 1: SQL Server database practical operation tips |
Page 1: SQL Server database practical operation tips |
Page 1: SQL Server database practical operation tips |
Page 1: SQL Server database practical operation tips |