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.