Published on: 04 August, 2014

How to create mysql database using sql syntax?

Tumblr Digg Google Plus

To create a database in sql database is pretty simple, you can just enter the following code.

   CREATE DATABASE database_name;

To check if a database is already exists, you can use the following syntax:

SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'database_name'

If you want to combine together to prevent an error message return when you try to create a database, you can use the keyword EXISTS. See below example syntax for more details.

CREATE DATABASE IF NOT EXISTS database_name;

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.