Example of how to create a database name with special characters in MySQL

Example of how to create a database name with special characters in MySQL

Preface

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

Here’s how

Use backticks ` to enclose the database name (quotation marks are not allowed). In the English input method state, press the Esc key to display the corresponding key below. Of course, if you do not use backticks to enclose the database name, an error will be reported if the database name contains special characters.

For example, using the following create command will result in an error:

mysql> CREATE DATABASE www.mafutian.net DEFAULT CHARSET UTF8;
1064 - Change the syntax of '.mafutian.net DEFAULT CHARSET UTF8' to the string 1

The correct way to create it:

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

As shown below:

Another example:

mysql> CREATE DATABASE `!@#$%^&*()_+.` DEFAULT CHARSET UTF8;
Query OK, 1 row affected
mysql> USE !@#$%^&*()_+.
 -> ;
1064 - I have read the syntax of '!@#$%^&*()_+.' to the letter 1
mysql> USE `!@#$%^&*()_+.`;
Database changed
mysql> SELECT database();
+---------------+
| database() |
+---------------+
| !@#$%^&*()_+. |
+---------------+
1 row in set

As can be seen from the above, when selecting a database, you also need to use backticks ` to quote the database name. As shown below:

Similarly, when deleting a database, you also need to use backticks to quote the database name:

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

Summarize

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • View, create and modify the encoding format of database and data table in MySQL
  • Two ways to create a MySQL database
  • MySQL commands for creating and deleting databases and related PHP script operations
  • MySQL Basic Database Creation
  • How to create a MySQL database (de1) using commands

<<:  JavaScript jigsaw puzzle game

>>:  A brief analysis of Docker private image library and Alibaba Cloud object storage OSS

Recommend

Implementation of MySQL Multi-version Concurrency Control MVCC

Table of contents What is MVCC MVCC Implementatio...

52 SQL statements to teach you performance optimization

1. To optimize the query, try to avoid full table...

Solutions to common problems using Elasticsearch

1. Using it with redis will cause Netty startup c...

SQL Practice Exercise: Online Mall Database Product Category Data Operation

Online shopping mall database-product category da...

How to generate a free certificate using openssl

1: What is openssl? What is its function? What is...

How to improve Idea startup speed and solve Tomcat log garbled characters

Table of contents Preface Idea startup speed Tomc...

Vue Virtual DOM Quick Start

Table of contents Virtual DOM What is virtual dom...

Detailed explanation of routes configuration of Vue-Router

Table of contents introduce Object attributes in ...

Docker online and offline installation and common command operations

1. Test environment name Version centos 7.6 docke...

Detailed explanation of the use of base tag in HTML

In requireJS, there is a property called baseURL....

This article teaches you how to play with CSS border

Border Style The border-style property specifies ...

You may not know these things about Mysql auto-increment id

Introduction: When using MySQL to create a table,...

An article explains Tomcat's class loading mechanism

Table of contents - Preface - - JVM Class Loader ...