Drop a keyspace (Go)
Drops a keyspace from a database and deletes all data in that keyspace.
Result
Drops the specified keyspace.
A successful operation does not return anything.
Signature
Use the DropKeyspace method, which belongs to the DataAPIDatabaseAdmin type.
func (a *DataAPIDatabaseAdmin) DropKeyspace(
ctx context.Context,
keyspace string,
opts ...options.DropKeyspaceOption
) error
Parameters
| Name | Type | Summary |
|---|---|---|
|
|
The context for the operation. |
|
|
The name of the keyspace to drop. |
|
Optional.
A builder to generate options for this operation.
See Methods of the |
| Method | Summary |
|---|---|
|
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(
options.API().SetEnvironment(options.EnvironmentHCD),
)
database := client.Database(
"API_ENDPOINT",
options.API().
SetUsernamePasswordTokenProvider(
"USERNAME",
"PASSWORD",
),
)
// 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)
}
}
Errors
For a full list of Data API error codes and their corresponding messages, see Data API errors and error codes.
For more information about how the client handles underlying Data API errors, see Go client error handling.
Client reference
For more information, see the client reference.