Skip to content

Commit 93a44c4

Browse files
authored
Merge pull request #32466 from rwestMSFT/rw-1121-fix-343606
Refresh database size article and clarify script (UUF 343606)
2 parents 288ee7a + 9c45bf8 commit 93a44c4

1 file changed

Lines changed: 60 additions & 67 deletions

File tree

docs/relational-databases/databases/increase-the-size-of-a-database.md

Lines changed: 60 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,71 @@ title: "Increase the Size of a Database"
33
description: "Increase the Size of a Database"
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
6-
ms.date: "03/14/2017"
6+
ms.reviewer: randolphwest
7+
ms.date: 11/21/2024
78
ms.service: sql
89
ms.topic: conceptual
910
helpviewer_keywords:
1011
- "databases [SQL Server], size"
1112
- "increasing database size"
1213
- "database size [SQL Server], increasing"
1314
- "size [SQL Server], databases"
14-
monikerRange: ">=sql-server-2016||>=sql-server-linux-2017"
15+
monikerRange: ">=sql-server-2016 || >=sql-server-linux-2017"
1516
---
16-
# Increase the Size of a Database
17-
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
18-
19-
This topic describes how to increase the size of a database in [!INCLUDE[ssnoversion](../../includes/ssnoversion-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)]. The database is expanded by either increasing the size of an existing data or log file or by adding a new file to the database.
20-
21-
**In This Topic**
22-
23-
- **Before you begin:**
24-
25-
[Limitations and Restrictions](#Restrictions)
26-
27-
[Security](#Security)
28-
29-
- **To increase the size of a database, using:**
30-
31-
[SQL Server Management Studio](#SSMSProcedure)
32-
33-
[Transact-SQL](#TsqlProcedure)
34-
35-
## <a name="BeforeYouBegin"></a> Before You Begin
36-
37-
### <a name="Restrictions"></a> Limitations and Restrictions
38-
39-
- You cannot add or remove a file while a BACKUP statement is running.
40-
41-
### <a name="Security"></a> Security
42-
43-
#### <a name="Permissions"></a> Permissions
44-
Requires ALTER permission on the database.
45-
46-
## <a name="SSMSProcedure"></a> Using SQL Server Management Studio
47-
48-
#### To increase the size of a database
49-
50-
1. In **Object Explorer**, connect to an instance of the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)], and then expand that instance.
51-
52-
2. Expand **Databases**, right-click the database to increase, and then click **Properties**.
53-
54-
3. In **Database Properties**, select the **Files** page.
55-
56-
4. To increase the size of an existing file, increase the value in the **Initial Size (MB)** column for the file. You must increase the size of the database by at least 1 megabyte.
57-
58-
5. To increase the size of the database by adding a new file, click **Add** and then enter the values for the new file. For more information, see [Add Data or Log Files to a Database](../../relational-databases/databases/add-data-or-log-files-to-a-database.md).
59-
60-
6. Click **OK**.
61-
62-
## <a name="TsqlProcedure"></a> Using Transact-SQL
63-
64-
#### To increase the size of a database
65-
66-
1. Connect to the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
67-
68-
2. From the Standard bar, click **New Query**.
69-
70-
3. Copy and paste the following example into the query window and click **Execute**. This example increases the size of the file `test1dat3`.
71-
72-
:::code language="sql" source="codesnippet/tsql/increase-the-size-of-a-d_1.sql":::
73-
74-
For more examples, see [ALTER DATABASE File and Filegroup Options &#40;Transact-SQL&#41;](../../t-sql/statements/alter-database-transact-sql-file-and-filegroup-options.md).
75-
76-
## See Also
77-
[Add Data or Log Files to a Database](../../relational-databases/databases/add-data-or-log-files-to-a-database.md)
78-
[Shrink a Database](../../relational-databases/databases/shrink-a-database.md)
79-
80-
17+
# Increase the size of a database
18+
19+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
20+
21+
This article describes how to increase the size of a database in [!INCLUDE [ssnoversion](../../includes/ssnoversion-md.md)] by using [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE [tsql](../../includes/tsql-md.md)]. The database is expanded by either increasing the size of an existing data or log file, or by adding a new file to the database.
22+
23+
## Limitations
24+
25+
You can't add or remove a file while a `BACKUP` statement is running.
26+
27+
## Permissions
28+
29+
Requires `ALTER` permission on the database.
30+
31+
<a id="SSMSProcedure"></a>
32+
33+
## Use SQL Server Management Studio
34+
35+
1. In **Object Explorer**, connect to an instance of the [!INCLUDE [ssDEnoversion](../../includes/ssdenoversion-md.md)], and then expand that instance.
36+
37+
1. Expand **Databases**, right-click the database to increase, and then select **Properties**.
38+
39+
1. In **Database Properties**, select the **Files** page.
40+
41+
1. To increase the size of an existing file, increase the value in the **Initial Size (MB)** column for the file. You must increase the size of the database by at least 1 megabyte.
42+
43+
1. To increase the size of the database by adding a new file, select **Add** and then enter the values for the new file. For more information, see [Add Data or Log Files to a Database](add-data-or-log-files-to-a-database.md).
44+
45+
1. Select **OK**.
46+
47+
<a id="TsqlProcedure"></a>
48+
49+
## Use Transact-SQL
50+
51+
1. Connect to the [!INCLUDE [ssDE](../../includes/ssde-md.md)].
52+
53+
1. From the Standard bar, select **New Query**.
54+
55+
1. Copy and paste the following example into the query window and select **Execute**.
56+
57+
This example changes the size of the file `test1dat3` to 200 MB.
58+
59+
```sql
60+
USE master;
61+
GO
62+
63+
ALTER DATABASE AdventureWorks2022
64+
MODIFY FILE (NAME = test1dat3, SIZE = 200 MB);
65+
GO
66+
```
67+
68+
For more examples, see [ALTER DATABASE (Transact-SQL) File and Filegroup Options](../../t-sql/statements/alter-database-transact-sql-file-and-filegroup-options.md).
69+
70+
## Related content
71+
72+
- [Add Data or Log Files to a Database](add-data-or-log-files-to-a-database.md)
73+
- [Shrink a database](shrink-a-database.md)

0 commit comments

Comments
 (0)