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

What is the MySQL database creation statement?

王林
Release: 2023-05-29 21:22:04
forward
3687 people have browsed it

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

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

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)
Copy after login
 4. When creating the database, specify the character encoding
mysql> create database yudb charset=gbk;
Copy after login

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!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template