We can create a new database by using ‘Create database databasename’ command. There are two conditions “IF EXISTS” or “IF NOT EXISTS” for us to apply which are optional.
The following are the steps to create new database.
- Firstly we must log in to the MySQL server and type root as a password.
- Before going to create a new database we have to check whether the database we are going to create is already exists or not. For this we use “show databases;” command. It displays the list of existing databases.
- Now we can create a new database as follows:
To display the created database we use show create database command.
We can create a new database using if not exists condition;
What happens when we try to create a database which is already exists by using if not exists condition.
It displays warning because the database ‘sports’ is already existed.
To watch this tutorial post on YouTube Channel.