SQL and T-SQL

One last thing to notice about this script is the CREATE DATABASE statement itself. More specifically, we don’t have to specify every option available. For the options we did not specify, SQL server will use default values. Also when we set the SIZE of the files, we don’t have to specify MB because MB is the default for the SIZE value (although for readability you may want to add MB anyway).

Once you have entered the statement, select Execute from the Query menu to see this output.
That’s it! We now have a new database created on our SQL Server.

You can also use the ALTER DATABASE statement to modify an existing database. For example, the following statement would add a new data file to the DBbySQL database with a size of 5MB and a Max size of 50MB:


USE master
GO
ALTER DATABASE DBbySQL
ADD FILE
(
NAME = DBbySQL_data2,
FILENAME = 'c:\DBbySQL_data2.ndf',
SIZE = 5MB,
MAXSIZE = 50MB
)
GO

For more information on the ALTER DATABASE statement see “ALTER DATABASE” in the SQL Server Books Online.