ADD FILE <filespec> [,…n] [TO FILEGROUP filegroup_name] ADD LOG FILE <filespec> [,…n] REMOVE FILE logical_file_name ADD FILEGROUP filegroup_name After a database is created, there may still come a time when you want to REMOVE FILEGROUP filegroup_name make changes to the way the files are MODIFY FILE <filespec> arranged. MODIFY FILEGROUP filegroup_name filegroup_property 4
<FileSpec> refers to the Logical_File_name refers to the
parameters of the file like Name, Name parameter without the file FileName, Size, Maxsize, and extension. FileGrowth.
It is vital to note that we may only apply one change per ALTER statement.
ADD FILE (NAME=Newdat1, First, we will add a secondary datafile to the Student2 database. This will FILENAME = ‘C:\Newdat.ndf’, need to happen with two ALTER SIZE = 10, statements. MAXSIZE = 100, FILEGROWTH = 5) TO FILEGROUP Secondary 6
ALTER DATABASE Student2
MODIFY FILE (NAME=Newdat1, FILENAME = ‘C:\Newdat1.ndf’, Now we will change a parameter FILEGROWTH = 15) value in the Student2 database. Let’s TO FILEGROUP Secondary say we needed to change the FileGrowth to 15. 7
ALTER DATABASE Student2
REMOVE FILE Newdat1
If we then decide to remove the ALTER DATABASE Student2
Secondary Filegroup, we will again We only have to REMOVE FILEGROUP Secondary have to make use of two ALTER specify the Logical statements. name of the data file and not the full file path. 8