Home > Database > Mysql Tutorial > What are the sql statements to create a database in mysql?

What are the sql statements to create a database in mysql?

下次还敢
Release: 2024-04-05 18:45:14
Original
613 people have browsed it

SQL statement to create a MySQL database: CREATE DATABASE database_name Optional parameters: CHARACTER SET charset_name: Specify character set COLLATE collation_name: Specify collation rules

What are the sql statements to create a database in mysql?

SQL statement to create a MySQL database

To create a MySQL database, you can use the following SQL statement:

<code class="sql">CREATE DATABASE database_name;</code>
Copy after login

Where, database_name is the database to be created The name.

Example:

To create a database named "my_database", you can use the following SQL statement:

<code class="sql">CREATE DATABASE my_database;</code>
Copy after login

Optional parameters :

CREATE DATABASE The statement can also include some optional parameters, such as:

  • ##CHARACTER SET charset_name:Specify the database character set.
  • COLLATE collation_name: Specify the collation rules of the database.

Example:

To create a database named "my_database" and use the UTF-8 character set and utf8_general_ci collation rules, you can use the following SQL Statement:

<code class="sql">CREATE DATABASE my_database CHARACTER SET utf8 COLLATE utf8_general_ci;</code>
Copy after login

The above is the detailed content of What are the sql statements to create a database in mysql?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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 Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template