How To Use SQL DROP DATABASE Statement With Example In PHP

admin_img Posted By Bajarangi soft , Posted On 18-09-2020

DROP DATABASE statement is used to drop or delete an existing SQL database.

SQL DROP DATABASE Statement

Syntax SQL DROP DATABASE Statement
 

DROP DATABASE databasename;

 
Example(1)

DROP DATABASE New_data_base;

SQL statement drops the existing database "New_data_base"

2.Complete code of DROP DATABASE Statement  in PHP script.
we can also DROP database by executing file .
 

<!DOCTYPE html>
<html lang="en">
<head>
    <title>SQL DROP  DATABASE Statement</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <br>
    <br>
    <br>
    <div class="text-center">
        <h1>SQL DROP  DATABASE Statement</h1>
    </div>
    <br>
    <br>
    <br>

    <div class="well">
        <?php
        $connect = mysqli_connect("localhost", "root", "", "school_management");
        if($connect === false){
            die("ERROR: Could not connect. " . mysqli_connect_error());
        }
        $sql = "DROP DATABASE New_data_base";
        if(mysqli_query($connect, $sql)){
            echo "<br><h1 class='text-success'>Database Dropped successfully.</h1>";
        } else{
            echo "ERROR: Could not able to execute $sql. " . mysqli_error($connect);
        }
        mysqli_close($connect);
        ?>
    </div>
    <br>
</div>
</body>
</html>

Related Post