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>    <bodystyle="text-align:center;">     <h1style="color:green;">           zambiatek       </h1>      <p>      HTML | indexedDB deleteDatabase() method     </p>     <buttononclick= "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, zambiatek 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!
 
				 
					



