Drop a collection

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

Method signature

  • Python

  • TypeScript

  • Java

  • curl

The following method belongs to the astrapy.Database class.

drop_collection(
    name: str,
    *,
    keyspace: str,
    collection_admin_timeout_ms: int,
    request_timeout_ms: int,
    timeout_ms: int,
) -> None:

The following method belongs to the Db class.

async dropCollection(
  name: string,
  options?: {
    keyspace?: string,
    timeout?: number | TimeoutDescriptor,
  }
): void

The following methods belong to the com.datastax.astra.client.Database class.

void dropCollection(String collectionName)
void dropCollection(
  String collectionName,
  DropCollectionOptions options
)
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.

The method returns None upon successful completion.

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

Returns a promise that resolves once the operation completes.

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

str

The name of the collection to drop.

keyspace

str

The keyspace containing the collection. If no keyspace is specified, the general setting for this database is used.

collection_admin_timeout_ms

int

A timeout, in milliseconds, for the underlying HTTP request. If not provided, the Database setting is used. This parameter is aliased as request_timeout_ms and timeout_ms for convenience.

Name Type Summary

name

string

The name of the collection to delete.

options?

DropCollectionOptions

Allows you to override the keyspace and set timeouts.

Name Type Summary

keyspace?

string

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

timeout

number | TimeoutDescriptor

Optional.

The timeout(s) to apply to this method. You can specify requestTimeoutMs and collectionAdminTimeoutMs.

Details about the timeout parameter

The TimeoutDescriptor object can contain these properties:

  • requestTimeoutMs (number): The maximum time, in milliseconds, that the client should wait for each underlying HTTP request. Default: The default value for the collection. This default is 10 seconds unless you specified a different default when you initialized the Collection or DataAPIClient object.

  • collectionAdminTimeoutMs (number): The maximum time, in milliseconds, for collection admin operations like creating, dropping, and listing collections. Default: The default value for the collection. This default is 60 seconds unless you specified a different default when you initialized the Collection or DataAPIClient object.

If you specify a number instead of a TimeoutDescriptor object, that number will be applied to both requestTimeoutMs and collectionAdminTimeoutMs.

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

result = db.drop_collection("COLLECTION")

Example:

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

database.list_collection_names()
# prints: ['a_collection', 'my_v_col', 'another_col']
database.drop_collection("my_v_col")
database.list_collection_names()
# prints: ['a_collection', 'another_col']

The database’s drop_collection method is equivalent to the collection’s own method collection.drop(). After invoking the latter, however, keep in mind that calling any subsequent operation on the collection will result in an error.

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
  await db.dropCollection('COLLECTION_NAME');

  // Overrides db's default keyspace
  await db.dropCollection('COLLECTION_NAME', {
    keyspace: 'KEYSPACE_NAME'
  });
})();

Example:

package com.datastax.astra.client.database;

import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.collections.commands.options.DropCollectionOptions;

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

    // Delete an existing collection
    DropCollectionOptions options = new DropCollectionOptions();
    db.dropCollection("collection_vector2", options);
  }
}

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