All Products
Search
Document Center

AnalyticDB:CREATE DATABASE

Last Updated:Mar 28, 2026

Creates a database in an AnalyticDB for MySQL cluster.

Syntax

CREATE DATABASE [IF NOT EXISTS] db_name

Parameter

`db_name`

The name of the database. The name must meet the following requirements:

RequirementDetails
LengthUp to 64 characters
First characterLowercase letter
Allowed charactersLetters, digits, and underscores (_)
Consecutive underscoresNot allowed (__)
Reserved namesCannot be analyticdb (the built-in system database)
Important

The database name cannot be changed after creation.

Usage notes

  • Each cluster supports up to 2,048 databases.

  • After creating a database, run USE db_name to switch to it before running table operations.

Example

Create a database named adb_demo:

CREATE DATABASE adb_demo;

Use a database

Run USE db_name to switch to a database after it is created.

USE adb_demo;
SHOW TABLES;

Expected output:

+------------------------------+
| Tables_in_adb_demo           |
+------------------------------+
| customer                     |
| test_table                   |
+------------------------------+