Drop a keyspace (Go)

Drops a keyspace from a database and deletes all data in that keyspace.

You need an application token with permission to interact with the target database, such as the Database Administrator role.

For more information, see Get endpoint and token.

Result

Drops the specified keyspace.

A successful operation does not return anything.

Parameters

Use the DropKeyspace method, which belongs to the AstraDatabaseAdmin type.

Method signature
func (a *AstraDatabaseAdmin) DropKeyspace(
  ctx context.Context,
  keyspace string,
  opts ...options.DropKeyspaceOption
) error
Name Type Summary

ctx

context.Context

The context for the operation.

keyspace

string

The name of the keyspace to drop.

opts

…​options.DropKeyspaceOption

Optional. A builder to generate options for this operation. See Methods of the DropKeyspaceOption builder for more details.

Methods of the DropKeyspaceOption builder
Method Summary

SetBlocking(v bool)

Optional. Whether to wait for the database to become active again before returning. If false, the method returns immediately after issuing the drop request, but you cannot work with the database until it becomes active again.

Default: true

SetPollInterval(v time.Duration)

Optional. Controls how often to check the database status if SetBlocking() is true.

Default: 10 seconds

UpdateAPIOptions(v …​APIOption)

Optional. General API options for this operation, including the timeout.

Examples

The following examples demonstrate how to drop a keyspace.

package main

import (
	"context"
	"log"

	"github.com/datastax/astra-db-go/v2/astra"
	"github.com/datastax/astra-db-go/v2/astra/options"
)

func main() {
	ctx := context.Background()

	// Get a database
	client := astra.NewClient()

	database := client.Database(
		"API_ENDPOINT",
		options.API().SetToken("APPLICATION_TOKEN"),
	)

	// Get an admin object
	admin, err := database.DatabaseAdmin()

	if err != nil {
		log.Fatal(err)
	}

	// Drop a keyspace
	err = admin.DropKeyspace(ctx, "KEYSPACE_NAME")

	if err != nil {
		log.Fatal(err)
	}
}

Client reference

For more information, see the client reference.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | 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: Contact IBM