You add a database using SQL Enterprise Manager or the CREATE DATABASE statement. This chapter describes the use of SQL Enterprise Manager. For information about using CREATE DATABASE and other statements, see the Microsoft SQL Server Transact-SQL Reference.
Creating a database allocates storage space for the database on a device. When you create a database, a transaction log is also created to record all transactions performed on that database. You should store the transaction log on a different device from the database to simplify recovery and to improve performance. If you do not specify a different device, the log is created as part of the database.
The Manage Databases window appears.
The New Database window appears. A default device is automatically listed in the Data Device box. A graph lists the devices for that server and shows the size and available space for each.
The name must comply with the SQL Server rules for identifiers. For information about these rules, see the Microsoft SQL Server Transact-SQL Reference.
When you open the New Database window, the Data Device box is automatically filled with the name of the first (sorted alphabetically) device. If you do not change the entry, that device is used.
Refer to the graph at the bottom of the dialog box for a display of the devices on the server and the available space on each.
By default, the maximum space available on the selected device is entered in this box. The legal values for Data Device Size range from 1 MB through 2 (23) MB. If the size you request is unavailable, SQL Enterprise Manager displays a message showing how much space is available.
When you open the New Database window, the Log Device box shows (none) selected. Unless you are creating very small, noncritical databases, you should always place the transaction log on a separate device from its database. This improves performance and allows you to keep backups of the log.
Refer to the graph at the bottom of the dialog box for a display of the devices on the server and the available space on each.
By default, the maximum space available on the selected device is entered in this box. In general, you should allocate from 10 to 25 percent of your database size for the transaction log. If the size you request is unavailable, SQL Enterprise Manager displays a message telling you how much space is available.
This results in more rapid database creation. With this option the pages are not zero-initialized when the database is created. However, users other than DBO cannot access the database until a backup is loaded into the database using SQL Enterprise Manager or the LOAD statement, and the database option DBO Use Only is cleared (off). For more information about this option, see the discussion of CREATE DATABASE FOR LOAD in the Microsoft SQL Server Transact-SQL Reference.
The database is added.
Note Each time you create a database, you should back up the master database. This makes recovery easier and safer in case master is later damaged. For information, see Chapter 12, Backing Up and Restoring.
When a database is created and the space allocation is specified for the database devices, SQL Server initializes every bit in the database devices to 0 (except for the allocation page for each 256-page block). However, if a device has not previously contained data, then the device will not be reinitialized, and database creation time is significantly reduced.
A database can occupy different amounts of space in each of several database devices. For information about extending the database across other devices, see Expanding or Shrinking Databases, later in this chapter.
Databases can also be created by using the CREATE DATABASE statement. The sp_helpdevice system procedure can be used to display a list of available devices that a new database can be placed on. For information, see the Microsoft SQL Server Transact-SQL Reference.
The creation of a new database is recorded in the sysdatabases table. Entries are also made in sysusages, which keeps track of the space allocated to databases.