How to Create a SQL Database

How to Create a SQL Database
Page content

Learning how to create a SQL database is actually quite simple. Microsoft SQL Server allows you to create databases that can link to applications and websites. SQL databases can be used separately as well, for a more powerful database than Microsoft Access. Before you can enter, manage, and manipulate data, you must create a SQL database to store all tables, stored procedures (sometimes called queries), database login information, and other permissions.

You can create a SQL database in one of two ways. The first is through Object Explorer. This method is the best for beginners and is the easiest for setting permissions for your database. The second is the CREATE DATABASE command, which allows you to create a query to create a new database with the arguments you provide. Anyone familiar with creating SQL queries or stored procedures will be comfortable using this method.

Object Explorer

Open an instance of SQL Server. In the Object Explorer window, drill down until you find the connection that you want to create a SQL database in. Before you can open a connection, you may need to log in first. Provide your user name and password to connect.

Expand the desired connection. Under the connection, there will be several options that are available. Right click “Databases” and choose “New Database.” Enter a name for your database. Use a name that is descriptive, especially if you plan on creating multiple databases. For instance, I’ll create a database to store employee information for the ABC Company. The title ABC_Employees is descriptive and short.

At this point, you can either accept the default values by pressing “OK” or continue through the available options to customize your database. You can change the owner of the database by pressing the “….” button. You can change options by selecting the “Options” page. For simple databases, stick with the default options. You can also change the configuration after the database is created.

Right click a created database and select “Properties.” Select “Options” to change the database’s configuration.

For more information on SQL database options, see Setting Database Options from MSDN.

CREATE DATABASE

Open a query editor window. You can do this from the SQL Server toolbar. Once a blank query window opens, type the following command “CREATE DATABASE databasename” where databasename is the name of your database. Using the example from the previous section, I would type CREATE DATABASE ABC_Employees. Please note that while case typically doesn’t matter, it is easier to use all caps for commands. Many users prefer to use all lowercase for database and table names to prevent any confusion. Execute the query using the query editor toolbar.

To customize your database options, you must add arguments to your query. If you do not wish to add arguments in the query itself, you can right click the database, select “Properties” and use the “Options” window. For more information on using arguments for the CREATE DATABASE command, see the MSDN article on the CREATE DATABASE command.

That’s all there is to it. You should now know how to create a SQL database.