SQL Tutorial SQL Advanced SQL Database SQL References

SQL CREATE DATABASE Keyword



The SQL CREATE DATABASE keyword is used to create a new SQL database.

Syntax

The syntax of using CREATE DATABASE statement is given below:

CREATE DATABASE DatabaseName;

Please note that to create any database, appropriate privilege is required. Along with this, the database name should be unique within the RDBMS. After creating the database, in MySQL and MariaDB, the following command can be used to see the list of available databases.

SHOW DATABASES;

Similarly in SQL Server, the following statement can be used to see the list of available databases.

SELECT name FROM sys.databases;

Example: create a database

To create a database with name testDB, the following statement can be used:

CREATE DATABASE testDB;

After creating the database, the SHOW DATABASES; command can be used to see the list of databases available in MySQL & MariaDB:

SHOW DATABASES;
Result:
+-------------+
| Database    |
+-------------+
| SQLExample1 |
| SQLExample2 |
| SQLExample3 |
| SQLExample4 |
| SQLExample5 |
| SQLExample6 |
| SQLExample7 |
| SQLExample8 |
| testDB      |
+-------------+
9 rows in set (0.00 sec)

Similarly in SQL Server, the following statement can be used to see the list of available databases.

SELECT name FROM sys.databases;
Result:

name        
--------------
SQLExample1 
SQLExample2 
SQLExample3 
SQLExample4 
SQLExample5 
SQLExample6 
SQLExample7 
SQLExample8 
testDB   

❮ SQL Keywords