MySQL database name method example with special characters, mysql Database Name

Source: Internet
Author: User
Tags syntaxe

MySQL database name method example with special characters, mysql Database Name

Preface

This article explains how to create a database name with special characters in MySQL. The special characters include :! @ # $ % ^

The method is as follows:

Use backticks to enclose the database name, and use backticks (quotation marks are not allowed). In the English input method, press the lower key corresponding to the Esc key. Of course, if the database name contains special characters, an error is returned if no backquotes are used to include the database name.

For example, an error is returned when you use the following creation command:

mysql> CREATE DATABASE www.mafutian.net DEFAULT CHARSET UTF8;1064 - Erreur de syntaxe près de '.mafutian.net DEFAULT CHARSET UTF8' à la ligne 1

Correct creation method:

mysql> CREATE DATABASE `www.mafutian.net` DEFAULT CHARSET UTF8;Query OK, 1 row affected

For example:

Other instances:

mysql> CREATE DATABASE `!@#$%^&*()_+.` DEFAULT CHARSET UTF8;Query OK, 1 row affectedmysql> USE !@#$%^&*()_+. -> ;1064 - Erreur de syntaxe près de '!@#$%^&*()_+.' à la ligne 1mysql> USE `!@#$%^&*()_+.`;Database changedmysql> SELECT database();+---------------+| database() |+---------------+| !@#$%^&*()_+. |+---------------+1 row in set

It can be seen from the above that when selecting a database, we also need to use the back quotation mark 'to cause the database name. For example:

Similarly, when deleting a database, we also need to use backquotes to enclose the Database Name:

mysql> DROP DATABASE `www.mafutian.net`;Query OK, 0 rows affectedmysql> DROP DATABASE `!@#$%^&*()_+.`;Query OK, 0 rows affected

Summary

The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.