Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

IDBFactory.deleteDatabase()

The deleteDatabase() method of the IDBFactory interface requests the deletion of a database. The method returns an IDBOpenDBRequest object immediately, and performs the deletion operation asynchronously.

If the database is successfully deleted, then a success event is fired on the request object returned from this method, with its result set to undefined. If an error occurs while the database is being deleted, then an error event is fired on the request object that is returned from this method.

Will trigger an upgradedneeded event and, if any other tabs have open connections to the database, a blocked event.

Note: This feature is available in Web Workers.

Syntax

For the current standard:

var request = window.indexedDB.deleteDatabase("toDoList");

For the experimental version with options (see below):

var request = window.indexedDB.deleteDatabase("toDoList", { storage: "temporary" });

Parameters

name
The name of the database.
options Non-standard
In Gecko, since version 26, you can include a non-standard optional storage parameter that specifies whether you want to delete a permanent (the default value) IndexedDB, or an indexedDB in temporary storage (aka shared pool.)

Return value

A IDBOpenDBRequest on which subsequent events related to this request are fired.

Example

var DBDeleteRequest = window.indexedDB.deleteDatabase("toDoList");

DBDeleteRequest.onerror = function(event) {
  console.log("Error deleting database.");
};
 
DBDeleteRequest.onsuccess = function(event) {
  console.log("Database deleted successfully");
    
  console.log(request.result); // should be null
};

Specifications

Specification Status Comment
Indexed Database API
The definition of 'deleteDatabase' in that specification.
Editor's Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 23webkit
24
10 moz
16.0 (16.0)
10, partial 15 7.1
Available in workers (Yes) 37.0 (37.0) ? (Yes) ?
Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support 4.4 22.0 (22.0) 1.0.1 10 22 8
Available in workers (Yes) 37.0 (37.0) (Yes) ? (Yes) ?

See also

Document Tags and Contributors

 Contributors to this page: jpmedley, Sebastianz, julienw, Brettz9, chrisdavidmills, fscholz
 Last updated by: jpmedley,