Additional info: by default a database is created with only a PRIMARY
filegroup, and even if you add filegroups later, PRIMARY
is the default for new objects unless you also change that setting (you can change the default, and a lot of people do) or override it explicitly when you create the object. So in a lot of cases the ON PRIMARY
bit is extraneous and inconsequential.
The reason you might not want to use the PRIMARY
filegroup for user objects is for things like piecemeal restore when recovering from a disaster - you can get the database online quicker if you restore the PRIMARY
filegroup and it's as small as possible, then you can restore your actual user data filegroup by filegroup, with the most important coming online first. Another reason might be that the initial data file for the PRIMARY
filegroup is on a slow(er) drive, and you want to expand the database by adding new files on fast(er) disks, well if you put those in their own filegroup and make that the default, all of your data goes to the fast(er) disks and only system/metadata stuff happens in the PRIMARY
filegroup on the slow disk.