Drop a collection

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

Ready to write code? See the examples for this method to get started. If you are new to the Data API, check out the quickstart.

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

Use the drop_collection method, which belongs to the astrapy.Database class.

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

The database’s drop_collection method is equivalent to the collection’s own collection.drop() method.

Name Type Summary

name

str

The name of the collection to drop.

keyspace

str

Optional. The keyspace containing the collection.

Default: The database’s working keyspace.

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.

Use the dropCollection method, which belongs to the Db class.

Method signature
async dropCollection(
  name: string,
  options?: {
    keyspace?: string,
    timeout?: number | TimeoutDescriptor,
  }
): void
Name Type Summary

name

string

The name of the collection to drop.

options

DropCollectionOptions

Optional. The options for this operation. See Properties of options for more details.

Properties of options
Name Type Summary

keyspace

string

Optional. The keyspace containing the collection.

Default: The database’s working keyspace.

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.

Use the dropCollection method, which belongs to the com.datastax.astra.client.Database class.

Method signature
void dropCollection(String collectionName)
void dropCollection(
  String collectionName,
  DropCollectionOptions options
)
Name Type Summary

collectionName

String

The name of the collection to drop.

options

DropCollectionOptions

Optional. The options for this operation, including the keyspace and timeouts.

Use the deleteCollection command.

Command signature
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "deleteCollection": {
    "name": "COLLECTION_NAME"
  }
}'
Name Type Summary

name

string

The name of the collection to delete.

Examples

The following examples demonstrate how to drop a collection.

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient

# Get a database
client = DataAPIClient()
database = client.get_database(
    "API_ENDPOINT",
    token="APPLICATION_TOKEN",
)

# Drop a collection
database.drop_collection("COLLECTION_NAME")
import { DataAPIClient } from "@datastax/astra-db-ts";

// Get a database
const client = new DataAPIClient("APPLICATION_TOKEN");
const database = client.db("API_ENDPOINT");

// Drop a collection
(async function () {
  await database.dropCollection("COLLECTION_NAME");
})();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;

public class Example {

  public static void main(String[] args) {
    // Get a database
    Database database = new DataAPIClient("APPLICATION_TOKEN").getDatabase("API_ENDPOINT");

    // Drop a collection
    database.dropCollection("COLLECTION_NAME");
  }
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "deleteCollection": {
    "name": "COLLECTION_NAME"
  }
}'

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