how to delete an entire database in mysql code example

Example 1: delete database mysql

DROP DATABASE dbname;

Example 2: MySQL DROP DATABASE

The DROP DATABASE statement drops all tables in the database and deletes the database permanently. Therefore, you should be very careful when using this statement.

The following shows the syntax of the DROP DATABASE statement:

DROP DATABASE [IF EXISTS] database_name;



In MySQL, the schema is the synonym for the database, therefore, you can use them interchangeably:

DROP SCHEMA [IF EXISTS] database_name;

Example 3: mysql remove database

mysql> drop database <db_name>;

Tags:

Sql Example