A ‘DROP TABLE table_name’ statement is used to delete the table.
Keywords :- How can i delete table with mysqli and pdo, delete table using pdo & mysqli
For Example Delete Table using MySQLi Code Syntax :-
<?php $server = "localhost"; $user = "root"; $password = ""; $db = "expertstutorials"; $conn = mysqli_connect($server, $user, $password, $db); if($conn){ echo "Connected successfully."; } else{ echo "Connection failed : ".mysqli_connect_error(); } $table_delete = "DROP TABLE course"; if (mysqli_query($conn, $table_delete)) { echo "Table Deleted successfully."; } else { echo "Could not delete table : " . mysqli_error($conn); } mysqli_close($conn); ?>
For Example Delete Table using MySQLi Code Syntax :-
<?php $server = 'localhost'; $user = 'root'; $password = ''; $db = 'expertstutorials'; try{ $conn = new PDO("mysql:host=$server;dbname=$db", $user, $password); echo "Connected successfully."; $table_delete = "DROP TABLE course"; $conn->exec($table_delete); echo "Table Deleted successfully."; } catch(PDOException $e){ echo "Could not delete table : " . $e->getMessage(); } $conn = null; ?>