You can execute the CREATE DATABASE
statement to create a database.
Creates a database
Note You can create up to 2,048 databases in each AnalyticDB for MySQL cluster.
- Syntax
CREATE DATABASE [IF NOT EXISTS] db_name
- Parameter
db_name
: the name of the database. The database name must meet the following requirements:- 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 the same as that of the built-in analyticdb database.
Important After you create a database, you cannot modify the name of the database. - Example
CREATE DATABASE adb_demo;
Use a database
You can execute the USE db_name
statement to use a database after it is created.
- Syntax
USE db_name
- Example
use adb_demo; show tables; +------------------------------+ | Tables_in_adb_demo | +------------------------------+ | customer | | test_table |