
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Drop Database in MySQL with Special Characters in Name
To drop a database with the character ‘?’ in its name, you need to use backtick symbol around the database name. The syntax is as follows −
DROP DATABASE `yourDatabaseName`;
To understand the above syntax, let us create a database. The query to create a database is as follows −
mysql> create database `test?data`; Query OK, 1 row affected (0.14 sec)
So, I have a database with? character. The query to show all databases is as follows −
mysql> show databases;
The following is the output −
+-----------------------+ | Database | +-----------------------+ | business | | commandline | | database1 | | databasesample | | education | | hb_student_tracker | | hello | | information_schema | | javadatabase2 | | javasampledatabase | | mybusiness | | mydatabase | | mysql | | onetomanyrelationship | | performance_schema | | rdb | | sample | | sampledatabase | | schemasample | | sys | | test | | test3 | | test?data | | universitydatabase | | web | | webtracker | +-----------------------+ 26 rows in set (0.09 sec)
To drop a database with? character, you need to use backtick symbol around the database name. The query is as follows −
mysql> drop database `test?data`; Query OK, 0 rows affected (0.32 sec)
Now you can check there is no database with test?data. The query is as follows −
mysql> show databases;
The following is the output −
+-----------------------+ | Database | +-----------------------+ | business | | commandline | | database1 | | databasesample | | education | | hb_student_tracker | | hello | | information_schema | | javadatabase2 | | javasampledatabase | | mybusiness | | mydatabase | | mysql | | onetomanyrelationship | | performance_schema | | rdb | | sample | | sampledatabase | | schemasample | | sys | | test | | test3 | | universitydatabase | | web | | webtracker | +-----------------------+ 25 rows in set (0.00 sec)
Look at the above output, there is no database with name test?data;
Advertisements