1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQL - の付いたデータベースの削除 

1
Last updated at Posted at 2019-12-19

今更ながら、データベースの整理をしていて - の付いたデータベースを削除する際にあれ?となったので。。。

ターミナル.
# mysql にログインします。rootの部分はユーザー名
$ mysql -u root




# データベースの確認
mysql> show databases;

+-----------------------------------+
| Database                          |
+-----------------------------------+
| information_schema                |
| mysql_development                 |
| mysql_test                        |
| mysql-app_development             |
| mysql-app_test                    |
+-----------------------------------+





# 通常の削除
mysql> drop database mysql_development;

実行結果
=> Query OK, 0 rows affected (0.00 sec)





# - の付いたデータベースの場合は
mysql> drop database mysql-app_development;

実行結果
=> ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-app_test' at line 1

エラーになってしまう。。。。






#  - の付いたデータベースを削除する際は ` (バッククオートで囲う)

 `  は shift+@ で入力

mysql> drop database `mysql-app_development`;

実行結果
=> Query OK, 0 rows affected (0.00 sec)



1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?