Default Filegroups

Creating and Maintaining Databases

Creating and Maintaining Databases

Default Filegroups

A database comprises a primary filegroup and any user-defined filegroups.

The filegroup that contains the primary file is the primary filegroup. When a database is created, the primary filegroup contains the primary data file and any other files that are not put into another filegroup. All system tables are allocated in the primary filegroup. If the primary filegroup runs out of space, no new catalog information can be added to the system tables. The primary filegroup only fills if either autogrow is turned off or all the disks holding the files in the primary filegroup run out of space. If this happens, either turn autogrow back on, or move other files off the disks to free more space.

User-defined filegroups are any filegroups that are specifically created by the user when first creating or later altering the database. If a user-defined filegroup fills up, only the user tables specifically allocated to that filegroup would be affected.

At any time, exactly one filegroup is designated as the DEFAULT filegroup. When objects are created in the database without specifying to which filegroup they belong, they are assigned to the default filegroup. The default filegroup must be large enough to hold any objects not allocated to a user-defined filegroup. Initially, the primary filegroup is the default filegroup.

The default filegroup can be changed using the ALTER DATABASE statement. By changing the default filegroup, any objects that do not have a filegroup specified when they are created are allocated to the data files in the new default filegroup. However, allocation for the system objects and tables remains within the PRIMARY filegroup, not the new default filegroup.

Changing the default filegroups prevents user objects that are not specifically created on a user-defined filegroup from competing with the system objects and tables for data space.

See Also

ALTER DATABASE