Dropping Databases : Drop Table « Table Index « SQL / MySQL






Dropping Databases

 
/*
mysql> DROP DATABASE MyDatabase;
Query OK, 0 rows affected (0.00 sec)

mysql> Show Databases;
+----------+
| Database |
+----------+
| info     |
| java2s   |
| mysql    |
| t        |
| test     |
| ttt      |
+----------+
6 rows in set (0.00 sec)

mysql> CREATE DATABASE MyDatabase;
Query OK, 1 row affected (0.00 sec)

mysql> Show Databases;
+------------+
| Database   |
+------------+
| info       |
| java2s     |
| mydatabase |
| mysql      |
| t          |
| test       |
| ttt        |
+------------+
7 rows in set (0.00 sec)

mysql> DROP DATABASE MyDatabase;
Query OK, 0 rows affected (0.00 sec)

mysql> Show Databases;
+----------+
| Database |
+----------+
| info     |
| java2s   |
| mysql    |
| t        |
| test     |
| ttt      |
+----------+
6 rows in set (0.00 sec)


*/

DROP DATABASE MyDatabase;
  
Show Databases;

CREATE DATABASE MyDatabase;

Show Databases;

DROP DATABASE MyDatabase;

Show Databases;
           
         
  








Related examples in the same category

1.Drop table if exists
2.In MySQL, a single DROP TABLE statement can name several tables to be dropped simultaneously
3.Add an IF EXISTS clause to the drop table statement
4.Drop more than one table at single statement