It is exceptionally simple to drop a current MySQLi table, yet you should be cautious while erasing any current table since information lost won't be recuperated subsequent to erasing a table.
Syntax
Here is conventional SQL language structure to drop a MySQLi table −
DROP TABLE table_name ;
Dropping Tables from Command Prompt
This requirements just to execute DROP TABLE SQL order at mysql> brief.
Example
Here is a model, which erases tutorials_inf −
root@host# mysql -u root -p
Enter password:*******
mysql> use TUTORIALS;
Database changed
mysql> DROP TABLE tutorials_inf
Query OK, 0 rows affected (0.8 sec)
mysql>
Dropping Tables Using PHP Script
To drop a current table in any data set, you would have to utilize PHP work mysqli_query(). You will pass its second contention with appropriate SQL order to drop a table.
Example
<html>
<head>
<title>Dropping MySQLi Tables</title>
</head>
<body>
<?php
$host = 'localhost:3306';
$user = 'root';
$pass = '';
$dbname = 'TUTORIALS';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn) {
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$sql = "DROP TABLE tutorials_inf";
if(mysqli_query($conn, $sql)) {
echo "Table is deleted successfully";
} else {
echo "Table is not deleted successfully\n";
}
mysqli_close($conn);
?>
</body>
</html>
The example yield ought to be this way −
Connected successfully
Table is deleted successfully