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.
When deleteDatabase()
is called, any other open connections to this particular database will get a versionchange event.
For the current standard:
var request = indexedDB.deleteDatabase(name);
For the experimental version with options
(see below):
var request = indexedDB.deleteDatabase(name, options);
IDBDatabase.deleteObjectStore()
, which does throw an exception if the named object store does not exist.permanent
(the default value) IndexedDB, or an indexedDB in temporary
storage (aka shared pool.)A IDBOpenDBRequest
on which subsequent events related to this request are fired.
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(event.result); // should be undefined };
Specification | Status | Comment |
---|---|---|
Indexed Database API 2.0 The definition of 'deleteDatabase()' in that specification. | Recommendation | |
Indexed Database API The definition of 'deleteDatabase()' in that specification. | Recommendation | Initial definition. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 24
|
12 | 16
|
10
|
15 | 7 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes
|
25 | Yes | 22 | 22 | 8 | Yes |
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/deleteDatabase