SQL Server database practical operation tips

Source: Internet
Author: User

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。
       
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Next Page
[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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.