MySQL Drop Table

drop table in my sql

MySQL Drop Table statement is to delete the existing table. This statement removes the complete data of a table along with the whole structure or definition permanently from the database.


DROP TABLE table_name ;

Dropping Tables from the Command Prompt

To drop tables from the command prompt, we need to execute the DROP TABLE SQL command at the my sql> prompt.


root@host# mysql -u root -p

Enter password:*******

mysql> use EDUSITES;

Database changed

mysql> DROP TABLE edusites_tbl

Query OK, 0 rows affected (0.8 sec)


Dropping Tables Using PHP Script

To drop an existing table in any database, you would need to use the PHP function mysql_query(). You will pass its second argument with a proper SQL command to drop a table.




      <title>Creating MySQL Tables</title>





         $dbhost = 'localhost:3036';

         $dbuser = 'root';

         $dbpass = 'rootpassword';

         $conn = mysql_connect($dbhost, $dbuser, $dbpass);


         if(! $conn ) {

            die('Could not connect: ' . mysql_error());


         echo 'Connected successfully<br />';

         $sql = "DROP TABLE tutorials_tbl";

         mysql_select_db( 'TUTORIALS' );

         $retval = mysql_query( $sql, $conn );


         if(! $retval ) {

            die('Could not delete table: ' . mysql_error());


         echo "Table deleted successfully\n";




Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *