Skip to main content

RenameCollection

This operation renames an existing collection.

go
func (c *Client) RenameCollection(ctx context.Context, option RenameCollectionOption, callOptions ...grpc.CallOption) error

Request Syntax​

Creates the request for RenameCollection().

go
option := milvusclient.NewRenameCollectionOption(oldName, newName)

err := client.RenameCollection(ctx, option)

PARAMETERS:

  • oldName (string) -

    [REQUIRED]

    The old name.

  • newName (string) -

    [REQUIRED]

    The new name for the collection.

BUILDER METHODS:

  • NewRenameCollectionOption(oldName string, newName string)

    Creates the request for RenameCollection().

RETURN TYPE:

error

RETURNS:

Returns nil on success, or an error describing what went wrong.

ERROR HANDLING:

  • error

    The operation fails. Check err != nil for failure details.

Example​

Demonstrates RenameCollection() usage.

go
import (
"context"
"log"

"github.com/milvus-io/milvus/client/v3/milvusclient"
)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

milvusAddr := "YOUR_CLUSTER_ENDPOINT"

cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: milvusAddr,
})
if err != nil {
log.Fatal("failed to connect to milvus server: ", err.Error())
}

defer cli.Close(ctx)

err = cli.RenameCollection(ctx, milvusclient.NewRenameCollectionOption("my_collection", "my_new_collection"))
if err != nil {
// handle error
}
Minimum SDK versionv3.0.x
Was this page helpful?