MySQL 8.0でデータベースを削除する

2021年12月20日

環境
Windows10 64bit
MySQL 8.0.27
Windowsコマンドプロンプト

書式
DROP DATABASE データベース名;

使用例
1.「userinfo」という名前のデータベースを作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> create database userinfo;
Query OK, 1 row affected (0.10 sec)
mysql> create database userinfo; Query OK, 1 row affected (0.10 sec)
mysql> create database userinfo;
Query OK, 1 row affected (0.10 sec)

2.作成したデータベースを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| userinfo |
| world |
+--------------------+
7 rows in set (0.00 sec)
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sakila | | sys | | userinfo | | world | +--------------------+ 7 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
| userinfo           |
| world              |
+--------------------+
7 rows in set (0.00 sec)

3.「userinfo」データベースを削除します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> drop database userinfo;
Query OK, 0 rows affected (0.09 sec)
mysql> drop database userinfo; Query OK, 0 rows affected (0.09 sec)
mysql> drop database userinfo;
Query OK, 0 rows affected (0.09 sec)

4.再度データベース一覧を確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| world |
+--------------------+
6 rows in set (0.07 sec)
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sakila | | sys | | world | +--------------------+ 6 rows in set (0.07 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
| world              |
+--------------------+
6 rows in set (0.07 sec)

 

MySQL

Posted by arkgame