MySQL CREATE DATABASE Statement
The CREATE DATABASE statement is used to create a new database in MySQL.
Syntax
CREATE DATABASE databasename;
- databasename: The name of the database you want to create.
Example
To create a database named ShopDB, you would use the following SQL statement:
CREATE DATABASE ShopDB;
Additional Options
You can also specify the character set and collation when creating the database, if necessary.
Syntax with character set and collation:
CREATE DATABASE databasename
CHARACTER SET utf8
COLLATE utf8_general_ci;
This creates a database with a specific character set (utf8) and collation (utf8_general_ci), which is commonly used for multi-language support.
Example with Character Set and Collation
CREATE DATABASE ShopDB
CHARACTER SET utf8
COLLATE utf8_general_ci;
This will create the ShopDB database with the UTF-8 character set, which is useful for handling international text.