How to delete the structure and data from the mysql database

-3

How to perform a complete deletion of the structure of a mysql database?

I need to delete all entidades , tabelas , procedures , I want to be only with the name of the database, without any table or data or anything else linked to that database.

Is there a command that does such a procedure?

    
asked by anonymous 08.01.2016 / 16:59

3 answers

1

You can kill the entire database and redo it with the same name:

DROP database 'meudatabase';
CREATE database 'meudatabase';

If you have a scritp to create the whole database even better, something like:

#Criando DATABASE
CREATE DATABASE 'meudatabase';

#Criando a tabela TABELA1
CREATE TABLE 'meudatabase'.'TABELA1' (
...
    
08.01.2016 / 17:05
0

Delete all tables from the database:

SELECT concat('DROP TABLE IF EXISTS ', TABLE_NAME, ';') FROM information_schema.TABLES;
    
08.01.2016 / 17:01
0

Oops, I found an answer in SOEN, take a look. link , I imagine it will help you.

drop

mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "drop table $table" DATABASE_NAME; done

truncate

mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "truncate table $table" DATABASE_NAME; done

    
08.01.2016 / 17:04