
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to DROP a database in MySQL with character '?' in its 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;
- Related Articles
- How to drop a database in MongoDB?
- How to drop a database in MongoDB using java?
- How can we drop a MySQL view from the database?
- How to drop a database using JDBC API?
- Can we create a database with a numeric name with MySQL?
- Create a MySQL stored procedure, which takes the name of the database as its parameter, to list the tables with detailed information in a particular database.
- How to update data in a MySQL database with Java?
- How to delete data in a MySQL database with Java?
- How to get field name types from a MySQL database?
- How can I check MySQL tables from a database in accordance with particular\ncolumn/s name?
- How to drop a table from a database using JDBC API?
- How can I drop a collection in MongoDB with two dashes in the name?
- How to drop a table from Oracle database using JDBC API?
- How to connect hibernate with MySQL Database?
- How can I check the character set of all the tables along with column names in a particular MySQL database?

Advertisements