Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. IDBDatabase
  4. deleteObjectStore()

IDBDatabase: deleteObjectStore() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

Note: This feature is available inWeb Workers.

ThedeleteObjectStore() method of theIDBDatabase interface destroys the object store with the given name inthe connected database, along with any indexes that reference it.

As withIDBDatabase.createObjectStore, this method can be calledonly within aversionchangetransaction.

Syntax

js
deleteObjectStore(name)

Parameters

name

The name of the object store you want to delete. Names arecase sensitive.

Return value

None (undefined).

Exceptions

InvalidStateErrorDOMException

Thrown if the method was not called from aversionchange transaction callback.

TransactionInactiveErrorDOMException

Thrown if a request is made on a source database that doesn't exist (E.g. has been deleted or removed.)

NotFoundErrorDOMException

Thrown when trying to delete an object store that does not exist.

Examples

js
const dbName = "sampleDB";const dbVersion = 2;const request = indexedDB.open(dbName, dbVersion);request.onupgradeneeded = (event) => {  const db = request.result;  if (event.oldVersion < 1) {    db.createObjectStore("store1");  }  if (event.oldVersion < 2) {    db.deleteObjectStore("store1");    db.createObjectStore("store2");  }  // etc. for version < 3, 4…};

Specifications

Specification
Indexed Database API 3.0
# ref-for-dom-idbdatabase-deleteobjectstore①

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp