To expand a database is to allocate additional device space to the database. If a database grows so that it uses most or all of the space allocated for it, you can expand it.
You expand a database using SQL Enterprise Manager or the ALTER DATABASE statement. This chapter describes the use of SQL Enterprise Manager. For information about using ALTER DATABASE and other statements, see the Microsoft SQL Server Transact-SQL Reference.
You can expand a database by allocating more space on its existing device or by allocating space on another device. A database can occupy more than one database device with different amounts of space on each. When expanding a database, you must increase the size of the database by at least 1 MB. Permission for expanding a database defaults to the database owner and is automatically transferred with database ownership. For information on permissions and database ownership, see Chapter 8, Security Concepts.
You cannot expand the master database on any device other than MASTER. If the master database requires more space, you can use SQL Enterprise Manager or the DISK RESIZE statement to increase the size of the MASTER device, and then expand the master database on the MASTER device. For information on expanding a device, see Chapter 5, Managing Devices.
The Manage Databases window appears.
The Edit Database window appears.
Under Information, the Size field shows the amount of space allocated to the database, and the Space Available field shows the amount of unused allocated space.
The Expand Database dialog box appears.
Refer to the graph at the bottom of the dialog box for a display of the devices on the server, and the available space on each.
If this is a device the database already has space on, enter the amount of additional space to allocate (not the total space). The default is the maximum space available on the selected device.
The Edit Database window returns.
Note While the database is expanded, the transaction log can also be expanded. For information about expanding transaction logs, see Expanding or Moving Transaction Logs, next in this chapter.
You can also expand the tempdb database, including tempdb in ram. However, when tempdb resides in RAM, it can only be altered 10 times without requiring the server to be shut down and restarted. Altering tempdb while it is in RAM causes each alteration of the database to allocate a new "chunk" of contiguous memory to tempdb. This memory, although it is contiguous, is not necessarily located next to the existing portion(s) of tempdb in RAM. To obtain maximum performance, the server should be stopped and restarted after tempdb is altered. For information about tempdb and tempdb in ram, see the Microsoft SQL Server Transact-SQL Reference.
If a database has been allocated unused space that you would like to recapture, you can shrink the database. In order to shrink a database, the database must be in single-user mode, but SQL Enterprise Manager sets this option automatically for you while it is shrinking the database.
The Manage Databases window appears.
The Edit Database window appears.
Under Information, the Size field shows the amount of space allocated to the database, and the Space Available field shows the amount of unused allocated space.
A message appears, informing you that the database will be set to single-user mode during the shrink operation, and asking whether or not to continue.
The Shrink Database dialog box appears.
There may be a delay before the minimum size is shown.
The database is set to single-user mode, the database is shrunk, and then the single-user setting is cleared. The Edit Database window returns.
You can also reduce the allocated space using DBCC SHRINKDB. To shrink the master or tempdb databases you must start the server in single-user mode (use the sqlservr command-line executable with the -m parameter) and use the DBCC SHRINKDB command. For information, see the Microsoft SQL Server Transact-SQL Reference.
Note After you expand or shrink a database, back up the master database.