SQL Drop Table



SQL Drop Table

MySql Drop Table declaration allow deleting tables from the MySql Database. After dropping tables, it removed all of its data permanently by using the SQL command. Since every table is separated by a comma, it is also possible to delete all tables by using “Drop Table” condition.


The first method :

DROP TABLE [table_name];

By writing this code in the command line, it will delete the table from the Database. In order to connect MySql server, you have to install some package from the command prompt.

For Linux; Install MySql on Ubuntu to the droplet, “sudo apt-get install mysql-server “ command should be written. After this step, “mysql –u root -p” command has to be typed into to terminal which provides to access the MySql shell.

For Windows; “C:\>cd \ MYSQL\Bin” and “C:\>cd \ MYSQL\Bin>mysql –u root –p admin” commands need to be written to the terminal.


In addition to this, the syntax of all statement for drop table is,

DROP [ Temporary ] TABLE  [If Exists ]

1_table_name, 2_table_name,

[Restrain | Progressive];

By writing this statement, it will drop the only Temporary tables from the Database and this statement allows dropping the tables without giving any error. It is also possible to give the name of tables specifically. Restraint and progressive have meant that it consists of porting the tables to the different databases.

For instance,

DROP TABLE 1_Table, 2_Table, .. ;

This query will check the tables, and if there exists any table like in the statement, it will be deleted with all data. However, if there is no table of the same name, there will be an error message on MySql.

DROP TABLE IF EXISTS 1_Table, 2_Table, ..;

This query is going to explore the tables separately and if it is caught the same table like in the query, it is going to be deleted from the Database. Otherwise, if it does not exist any message will be displayed.


Previous articleSQL Create Table
Next articleSQL INSERT INTO Statement
Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.