Drop a collection

Deletes a collection from a database and erases all data stored in the collection.

Method signature

  • Python

  • TypeScript

  • Java

  • curl

database.drop_collection(
  name_or_collection: str | Collection,
  *,
  max_time_ms: int,
) -> dict[str, Any]
database.dropCollection(
  name: string,
  options?: {
    maxTimeMS?: number,
    keyspace?: string,
  }
): Promise<boolean>
void dropCollection(String collectionName)
curl -sS -L -X POST "ASTRA_DB_API_ENDPOINT/api/json/v1/ASTRA_DB_KEYSPACE" \
--header "Token: ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "deleteCollection": {
    "name": "COLLECTION_NAME"
  }
}'

Result

  • Python

  • TypeScript

  • Java

  • curl

Deletes the specified collection from the database and erases all data stored in the collection.

If the method succeeds, returns a dictionary in the form {"ok": 1}.

Deletes the specified collection from the database and erases all data stored in the collection.

Returns a promise that resolves to true if the method succeeds.

Deletes the specified collection from the database and erases all data stored in the collection.

Does not return anything.

Deletes the specified collection from the database and erases all data stored in the collection.

If the command succeeds, the response indicates the success.

Example response:

{
  "status": {
    "ok": 1
  }
}

Parameters

  • Python

  • TypeScript

  • Java

  • curl

Name Type Summary

name_or_collection

str | Collection

either the name of a collection or a Collection instance.

max_time_ms

Optional[int]

A timeout, in milliseconds, for the underlying HTTP request.

Name Type Summary

name

string

The name of the collection to delete.

options?

DropCollectionOptions

Allows you to override the keyspace and set a maxTimeMs.

Name Type Summary

keyspace?

string

The keyspace containing the collection. If not specified, the database’s working keyspace is used.

maxTimeMS?

number

Maximum time in milliseconds the client should wait for the operation to complete.

Name Type Summary

collectionName

String

The name of the collection to delete.

Name Type Summary

deleteCollection

command

The command to delete a specified collection and all of its data.

name

string

The name of the collection to delete.

Examples

The following examples demonstrate how to drop a collection.

  • Python

  • TypeScript

  • Java

  • curl

This command is equivalent to the collection’s own method collection.drop().

result = db.drop_collection(name_or_collection="COLLECTION")

Example:

from astrapy import DataAPIClient
client = DataAPIClient("TOKEN")
database = client.get_database("API_ENDPOINT")

database.list_collection_names()
# prints: ['a_collection', 'my_v_col', 'another_col']
database.drop_collection("my_v_col")  # {'ok': 1}
database.list_collection_names()
# prints: ['a_collection', 'another_col']
const ok = await db.dropCollection('COLLECTION');

Example:

import { DataAPIClient } from '@datastax/astra-db-ts';

// Get a new Db instance
const db = new DataAPIClient('TOKEN').db('API_ENDPOINT');

(async function () {
  // Uses db's default keyspace
  const success1 = await db.dropCollection('COLLECTION_NAME');
  console.log(success1); // true

  // Overrides db's default keyspace
  const success2 = await db.dropCollection('COLLECTION_NAME', {
    keyspace: 'KEYSPACE_NAME'
  });
  console.log(success2); // true
})();
// Given `db` Database object, list all collections
void db.dropCollection("collectionName");

Example:

package com.datastax.astra.client.database;

import com.datastax.astra.client.Database;

public class DropCollection {
  public static void main(String[] args) {
    Database db = new Database("API_ENDPOINT", "TOKEN");

    // Delete an existing collection
    db.dropCollection("collection_vector2");
  }
}

To delete a collection and all data that it contains, send a POST request with the deleteCollection command:

curl -sS -L -X POST "ASTRA_DB_API_ENDPOINT/api/json/v1/ASTRA_DB_KEYSPACE" \
--header "Token: ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "deleteCollection": {
    "name": "COLLECTION_NAME"
  }
}' | jq

Client reference

  • Python

  • TypeScript

  • Java

  • curl

For more information, see the client reference.

For more information, see the client reference.

For more information, see the client reference.

Client reference documentation is not applicable for HTTP.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com