Saturday, November 15, 2025
HomeLanguagesJavascriptHTML DOM indexedDB deleteDatabase() Method

HTML DOM indexedDB deleteDatabase() Method

The indexedDB deleteDatabase() method is used to request the deletion of a database. The method returns an IDBOpenDBRequest object immediately and performs the deletion operation asynchronously.

Syntax:

var request = indexedDB.deleteDatabase(name);

Parameters: 

  • name: The name of the database you want to delete.

Return value: A IDBOpenDBRequest object after deletion.

Example: In this example, we will open a database and hence, will delete that database using this method.




<!DOCTYPE HTML> 
<html>  
<head>
    <title>indexedDB deleteDatabase() method</title>
</head>   
<body style="text-align:center;">
    <h1 style="color:green;">  
        neveropen  
    </h1
    <p
    HTML | indexedDB deleteDatabase() method
    </p>
    <button onclick = "Geeks()">
    Click Here
    </button>     
    <script>
        function Geeks(){
         var request = 
     window.indexedDB.open("newDatabase", 1);
         var DBDeleteReq = 
     window.indexedDB.deleteDatabase("newDatabase");
         DBDeleteReq.onsuccess = function(event) {
              console.log("Database deleted successfully");
}
            console.log(DBDeleteReq);
             console.log(window.indexedDB.databases());
     }
  </script
</body>   
</html>


Output:
Before Button Click:

After Button Click: In the console, the IDBOpenDBRequest object can be seen with a successful delete message.
Also, on checking databases, an Array with 0 databases can be seen.

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7143 POSTS0 COMMENTS
Thapelo Manthata
6838 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS