Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - "CREATE DATABASE" Statement - Creating New Databases
(Continued from previous topic...)
How to create new databases with "CREATE DATABASE" statements?
This is the first tutorial of a quick lesson on creating database objects with
This lesson shows you how to create a database, create a table in the database,
and then access and change the data in the table.
Because this lesson is an introduction to using Transact-SQL,
it does not use or describe the many options that are available for these statements.
This tutorial assumes that you are running SQL Server Management Studio Express.
Like many Transact-SQL statements, the CREATE DATABASE statement has
a required parameter: the name of the database. CREATE DATABASE also
has many optional parameters, such as the disk location where you want
to put the database files. When you execute CREATE DATABASE without
the optional parameters, SQL Server uses default values for many
of these parameters. This tutorial uses very few of the optional syntax parameters.
To create a database -
In a Query Editor window, type but do not execute the following code:
CREATE DATABASE TestData
Use the pointer to select the words CREATE DATABASE, and then press F1.
The CREATE DATABASE topic in SQL Server 2005 Books Online should open.
You can use this technique to find the complete syntax for CREATE DATABASE
and for the other statements that are used in this tutorial.
In Query Editor, press F5 to execute the statement and create a database named TestData.
When you create a database, SQL Server makes a copy of the model database, and renames the copy to the database name. This operation should only take several seconds, unless you specify a large initial size of the database as an optional parameter.
(Continued on next topic...)
- How to use Transact-SQL statements to access the database engine?
- How to create new databases with "CREATE DATABASE" statements?
- How to create new table with "CREATE TABLE" statements?
- How to insert and update data into a table with "INSERT" and "UPDATE" statements?
- How to read data in a table with "SELECT" statements?
- How to create a login to access the database engine using "CREATE LOGIN" statements?
- How to create a user to access a database using "CREATE USER" statements?
- How to create a view and a stored procedure using "CREATE VIEW/PROCEDURE" statements?
- How to grant a permission using "GRANT EXECUTE" statements?
- How to delete database objects with "DROP" statements?