Creates a database in an AnalyticDB for MySQL cluster.
Syntax
CREATE DATABASE [IF NOT EXISTS] db_nameParameter
`db_name`
The name of the database. The name must meet the following requirements:
| Requirement | Details |
|---|---|
| Length | Up to 64 characters |
| First character | Lowercase letter |
| Allowed characters | Letters, digits, and underscores (_) |
| Consecutive underscores | Not allowed (__) |
| Reserved names | Cannot 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_nameto 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 |
+------------------------------+