All Products
Search
Document Center

AnalyticDB:CREATE DATABASE

Last Updated:Aug 24, 2026

The CREATE DATABASE syntax in AnalyticDB for MySQL is fully compatible with MySQL. In AnalyticDB for MySQL, a database corresponds to a logical database, and data is automatically distributed across multiple nodes in the cluster.

Limits

  • Each cluster supports up to 2,048 databases.

  • The database name cannot be modified after the database is created. To change the database name, create a new database and migrate the data.

  • The CHARACTER SET and COLLATE clauses are not supported for specifying character sets. All databases use UTF-8 encoding.

Syntax

CREATE DATABASE [IF NOT EXISTS] db_name
  • db_name: the name of the database. The name must follow these rules:

    • The name can be up to 64 characters in length.

    • The name must start with a lowercase letter.

    • The name can contain letters, digits, and underscores (_).

    • The name cannot contain consecutive underscores (_).

    • The name cannot be analyticdb, which is a reserved name for the built-in database.

  • IF NOT EXISTS: If the specified database already exists, no error is returned and no new database is created.

Examples

Create a database named adb_demo:

CREATE DATABASE adb_demo;

Create a database only if it does not already exist:

CREATE DATABASE IF NOT EXISTS adb_demo;

Use a database

After a database is created, run the USE db_name statement to switch to the database:

USE adb_demo;

You can then view the tables in the database:

SHOW TABLES;
+------------------------------+
| Tables_in_adb_demo           |
+------------------------------+
| customer                     |
| test_table                   |
+------------------------------+