SQL Create Database

You can create a database using the CREATE DATABASE command.

SQL syntax

Example Code

This statement creates a database called Payroll. Because no arguments have been specified, the database data files and transaction logs will be created automatically in the default location.

Adding Arguments

There are a number of optional arguments that you can supply with the CREATE DATABASE command. You should check your database system's documentation for the specific arguments supported and their usage, but here's an example of supplying arguments when creating a database using Microsoft's SQL Server.

Example Code

In this example, we are supplying the name and location of the database's data file and transaction log. We are also specifying the initial size of these files (with the SIZE argument), the maximum size it can grow to (with the MAXSIZE argument) and the growth increment of each file (using the FILEGROWTH) argument.

Note that in SQL Server the GO keyword is used to indicate the end of a batch. This keyword is not necessary in MySQL and other database management systems.

Next up is the CREATE TABLE command.