CREATE DATABASE command is used to create a database in MariaDB, CREATE SCHEMA is a synonym for creating a database.
Syntax :
CREATE DATABASE Database_name;
If the optional OR REPLACE clause is used, it acts as a shortcut for :
DROP DATABASE IF EXISTS db-name;
CREATE DATABASE db-name;
IF NOT EXISTS :
When IF NOT EXISTS clause is used, MariaDB will return a warning instead of an error if the specified database is already exist.
For example :
Output :
Query OK, 1 row affected (0.01 sec)
CREATE OR REPLACE DATABASE student;
Output :
Query OK, 2 rows affected (0.00 sec)
CREATE DATABASE IF NOT EXISTS student;
Output :
Query OK, 1 row affected, 1 warning (0.01 sec)
Warning :
Level :Note
Code : 1007
Message : Can't create database 'student' ; database exists
SHOW DATABASE : This command is used to see the database you have created
Syntax :