CREATE DATABASE

Description

Create a database.

Syntax

  1. > CREATE DATABASE [IF NOT EXISTS] <database_name> [create_option] ...
  2. > create_option: [DEFAULT] {
  3. CHARACTER SET [=] charset_name
  4. | COLLATE [=] collation_name
  5. | ENCRYPTION [=] {'Y' | 'N'}
  6. }

Examples

  1. CREATE DATABASE IF NOT EXISTS test01;

Expected Result

You can use SHOW DATABASES to check if the databases have been created.

  1. mysql> show databases;
  2. +--------------------+
  3. | Database |
  4. +--------------------+
  5. | mo_task |
  6. | information_schema |
  7. | mysql |
  8. | system_metrics |
  9. | system |
  10. | test01 |
  11. | mo_catalog |
  12. +--------------------+
  13. 10 rows in set (0.01 sec)

You can see that the new database test01 has been created in addition to the six system databases.

Constraints

  • Only UTF-8 CHARACTER SET is supported for now.
  • CHARACTER SET, COLLATE, ENCRYPTION can be used but don’t work.