SQL CREATE DATABASE

SQL CREATE DATABASESummary: in this tutorial, you will learn how to create new databases using SQL CREATE DATABASE statement.

A database is a container that contains all objects including tables, indexes, views, stored procedures, triggers and data. To create a new database, you must have create database privilege in the database server.

You use the CREATE DATABASE statement to create a new database. The syntax of the  CREATE DATABASE statement is as follows:

You need to specify the database name followed the  CREATE DATABASE clause. There are some important points that you should remember when naming a new database:

  • The database name should be as descriptive as possible. It should describe the nature of data it contains e.g., HR, Productions, Customers, and Vendors, etc.
  • The database name has to be unique in a database server. Some database products have a restriction on the length of the database name e.g., in Microsoft SQL Server, the database name can be up to 128 characters.
  • In some platforms such as UNIX and LINUX, the name of database is case sensitive therefore you should use a consistent database name e.g., lowercase, uppercase or camel case.

SQL CREATE DATABASE example

We can use the  CREATE DATABASE statement to create the  Northwind database, which is the sample database that we are using in our SQL tutorials as the following statement:

For more information on how to create a new database:

In this tutorial, you have learned how to use the  CREATE DATABASE statement to create new databases.