A database is a container that holds all your tables. A table is a container for a subset of your data. A table holds data organized in rows and columns. Consider a column to be a piece of data that is an attribute of an entity. A row is a set of columns that define attributes of an entity
The relationships are conceptually shown below:
![How to Create a database in MySQL 1](https://onurdesk.com/wp-content/uploads/2020/12/image-13-1024x567.png)
In this post, we’ll learn how to use the CREATE statement. We can use the CREATE statement to create a database.
-- The post queries are reproduced below for convenient copy/paste into the terminal.
-- Query 1
CREATE DATABASE MovieIndustry;
-- Query 2
CREATE DATABASE IF NOT EXISTS MovieIndustry;
-- Query 3
SHOW DATABASES;
-- Query 4
DROP DATABASE MovieIndustry;
This Articles Contents
CREATE DATABASE
Let’s create the database first. We’ll name it MovieIndustry.
CREATE DATABASE MovieIndustry;
![How to Create a database in MySQL 2](https://onurdesk.com/wp-content/uploads/2020/12/image-14-1024x122.png)
![How to Create a database in MySQL 2](https://onurdesk.com/wp-content/uploads/2020/12/image-14-1024x122.png)
CREATE DATABASE IF NOT EXISTS
If we attempt to re-create an existing database, MySQL will report an error. We can circumvent this error by using the IF NOT EXISTS command as shown below:
CREATE DATABASE IF NOT EXISTS MovieIndustry;
![How to Create a database in MySQL 3](https://onurdesk.com/wp-content/uploads/2020/12/image-15-1024x101.png)
![How to Create a database in MySQL 3](https://onurdesk.com/wp-content/uploads/2020/12/image-15-1024x101.png)
The IF NOT EXISTS clause is useful when writing scripts that may be invoked repeatedly and will abort when creating a database that already exists.
When we create a database, MySQL creates a physical directory by the same name. Directories are case-sensitive in Linux and Mac, and correspondingly, MySQL will take the case into account. On a Linux or Mac, MovieIndustry isn’t the same as movieindustry as shown below:
![How to Create a database in MySQL 4](https://onurdesk.com/wp-content/uploads/2020/12/image-16-1024x158.png)
![How to Create a database in MySQL 4](https://onurdesk.com/wp-content/uploads/2020/12/image-16-1024x158.png)
Windows operating system is case-insensitive, and we can use MovieIndustry and movieindustry interchangeably.
SHOW DATABASES
Now you can inspect the database you created by using the following command:
SHOW DATABASES;
The output lists all the databases in the system and one of them is MovieIndustry.
![How to Create a database in MySQL 5](https://onurdesk.com/wp-content/uploads/2020/12/image-17-1024x329.png)
![How to Create a database in MySQL 5](https://onurdesk.com/wp-content/uploads/2020/12/image-17-1024x329.png)
DROP DATABASE
We can drop a database using the DROP statement. All the tables, indexes, and other structures created within the database are also deleted.
DROP DATABASE MovieIndustry;
![How to Create a database in MySQL 6](https://onurdesk.com/wp-content/uploads/2020/12/image-18-1024x717.png)
![How to Create a database in MySQL 6](https://onurdesk.com/wp-content/uploads/2020/12/image-18-1024x717.png)