Home >Database >Mysql Tutorial >What is the MySQL database creation statement?

What is the MySQL database creation statement?

王林
王林forward
2023-05-29 21:22:043597browse

  Syntax: create database [if not exists] Database name [option]

 1. Create database
mysql> create database stu;
Query OK, 1 row affected (0.01 sec)
 2. When creating a database, the database already exists Error
 ERROR 1007 (HY000): Can't create database 'stu'; database exists

When creating the database, determine whether the database exists. If it does not exist, create it

3. Use special characters and keywords as the database name

Use backticks to change the database name Include it. ``

mysql> create database `create`
mysql> create database `$%`;
Query OK, 1 row affected (0.00 sec)
 4. When creating the database, specify the character encoding
mysql> create database yudb charset=gbk;

If no encoding is specified, the database will default to the encoding specified when installing the database

The above is the detailed content of What is the MySQL database creation statement?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete