CREATE, DROP, and USE Databases
In this lesson, we will look at the syntax for creating and deleting a database.
We'll cover the following
CREATE DATABASE
The SQL CREATE DATABASE statement is used to create a new SQL database.
Syntax
The basic syntax of this CREATE DATABASE
statement is as follows:
CREATE DATABASE DatabaseName;
The database name should always be unique within the RDBMS.
Keep in mind that SQL keywords are NOT case sensitive: create
is the same as CREATE
.
Also, some database systems require a semicolon at the end of each SQL statement. A semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
Example
If you want to create a new database, for example, testDB1, then the CREATE DATABASE
statement would be as shown below:
CREATE DATABASE testDB1;
Now let’s create two databases in the code below: