1. Create DATABASE syntax:
CREATE {DATABASE | SCHEMA} [IF not EXISTS] Db_name
[Create_specification [, Create_specification] ...]
Note: CREATE DATABASE is used for creating databases and naming them. If you want to use CREATE database, you need to get the Create permissions for the databases . If the database exists and you do not specify an if not EXISTS, an error occurs.
Create_specification:
[DEFAULT] CHARACTER SET Charset_name
| [DEFAULT] COLLATE collation_name
Note: Thecreate_specification option is used to specify the attributes of the database. Database attributes are stored in the db.opt file in the database directory. The CHARACTER set clause is used to specify the default database character set. The COLLATE clause is used to specify the default database collation.
Some directories contain files that correspond to tables in the database. Databases in MySQL are executed in the same way as these directories do. Because there are no tables in the database when the database was just created, create database creates only one directory. This directory is located under the MySQL data directory and the db.opt file.
If you manually create a directory under the data directory (for example, using mkdir), the server considers this a database directory and displays it in the output of show databases.
You can also use the Create SCHEMA.
----------
2. Modify the database syntax:
ALTER {DATABASE | SCHEMA} [Db_name] alter_specification [, alter_specification] ...
NOTE:alter database is used to change the global nature of the databases. These attributes are stored in the db.opt file in the database directory. In order to use ALTER DATABASE, you need to obtain the ALTER permission for the databases .
alter_specification:
[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_name
Note: TheCHARACTER set clause is used to change the default database character set; theCOLLATE clause is used to change the default database collation.
The database name [db_name] can be ignored, at which point the statement corresponds to the default database. You can also use the Alter SCHEMA.
MySQL Create and modify database syntax