|
1 | 1 | --- |
2 | 2 | title: "Shrink a database" |
3 | | -description: Learn how to shrink a database by using Object in SQL Server by using SQL Server Management Studio or Transact-SQL. |
| 3 | +description: Learn how to shrink a database in SQL Server by using SQL Server Management Studio or Transact-SQL. |
4 | 4 | author: WilliamDAssafMSFT |
5 | 5 | ms.author: wiassaf |
6 | 6 | ms.reviewer: randolphwest |
7 | | -ms.date: 04/04/2023 |
| 7 | +ms.date: 11/01/2023 |
8 | 8 | ms.service: sql |
9 | 9 | ms.subservice: supportability |
10 | 10 | ms.topic: conceptual |
@@ -54,8 +54,12 @@ Requires membership in the **sysadmin** fixed server role or the **db_owner** fi |
54 | 54 |
|
55 | 55 | Shrink operations in progress can block other queries on the database, and can be blocked by queries already in progress. Introduced in [!INCLUDE[sssql22-md](../../includes/sssql22-md.md)], shrink database operations have a WAIT_AT_LOW_PRIORITY option. This feature is a new additional option for `DBCC SHRINKDATABASE` and `DBCC SHRINKFILE`. If a new shrink operation in WAIT_AT_LOW_PRIORITY mode can't obtain the necessary locks due to a long-running query already in progress, the shrink operation will eventually time out after one minute and silently exit, preventing other queries from being blocked. For more information, see [DBCC SHRINKDATABASE](../../t-sql/database-console-commands/dbcc-shrinkdatabase-transact-sql.md). |
56 | 56 |
|
| 57 | +For information on file management and shrink operations specific to Azure SQL Database, see [Manage file space for databases in Azure SQL Database](/azure/azure-sql/database/file-space-manage?view=azuresql-db&preserve-view=true). |
| 58 | + |
57 | 59 | ## <a id="SSMSProcedure"></a> Use SQL Server Management Studio |
58 | 60 |
|
| 61 | +**Applies to:** SQL Server, Azure SQL Managed Instance |
| 62 | + |
59 | 63 | #### Shrink a database |
60 | 64 |
|
61 | 65 | 1. In **Object Explorer**, connect to an instance of the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)], and then expand that instance. |
@@ -98,21 +102,19 @@ Shrink operations in progress can block other queries on the database, and can b |
98 | 102 |
|
99 | 103 | [!code-sql[DBCC#DBCC_SHRINKDB1](codesnippet/tsql/shrink-a-database_1.sql)] |
100 | 104 |
|
101 | | -## <a id="FollowUp"></a> Follow Up: After you shrink a database |
| 105 | +## <a id="FollowUp"></a> After you shrink a database |
102 | 106 |
|
103 | 107 | Data that is moved to shrink a file can be scattered to any available location in the file. This causes index fragmentation and can slow the performance of queries that search a range of the index. To eliminate the fragmentation, consider rebuilding the indexes on the file after shrinking. For more information, see [Rebuild an index](../../relational-databases/indexes/reorganize-and-rebuild-indexes.md#rebuild-an-index). |
104 | 108 |
|
105 | | -## See also |
| 109 | +## Related content |
106 | 110 |
|
107 | 111 | - [Shrink the tempdb database](shrink-tempdb-database.md) |
108 | 112 | - [Considerations for the autogrow and autoshrink settings in SQL Server](/troubleshoot/sql/admin/considerations-autogrow-autoshrink) |
109 | 113 | - [Database Files and Filegroups](database-files-and-filegroups.md) |
110 | 114 | - [sys.databases (Transact-SQL)](../../relational-databases/system-catalog-views/sys-databases-transact-sql.md) |
111 | 115 | - [sys.database_files (Transact-SQL)](../../relational-databases/system-catalog-views/sys-database-files-transact-sql.md) |
112 | | - |
113 | | -## Next steps |
114 | | - |
115 | 116 | - [DBCC SHRINKDATABASE (Transact-SQL)](../../t-sql/database-console-commands/dbcc-shrinkdatabase-transact-sql.md) |
116 | 117 | - [DBCC SHRINKFILE (Transact-SQL)](../../t-sql/database-console-commands/dbcc-shrinkfile-transact-sql.md) |
117 | 118 | - [Delete Data or Log Files from a Database](delete-data-or-log-files-from-a-database.md) |
118 | 119 | - [Shrink a file](shrink-a-file.md) |
| 120 | +- [Manage file space for databases in Azure SQL Database](/azure/azure-sql/database/file-space-manage?view=azuresql-db&preserve-view=true) |
0 commit comments