Skip to main content

renameCollection()

Addedv2.3.xModifiedv2.6.x

This operation renames an existing collection.

public void renameCollection(RenameCollectionReq request)

Request Syntax

renameCollection(RenameCollectionReq.builder()
.databaseName(String databaseName)
.collectionName(String collectionName)
.newCollectionName(String newCollectionName)
.build()
);

BUILDER METHODS:

  • databaseName(String databaseName) -

    The name of the database. Defaults to the current database if not specified.

  • collectionName(String collectionName) -

    The name of the target collection.

  • newCollectionName(String newCollectionName) -

    The new name for the collection.

RETURNS:

void

EXCEPTIONS:

  • MilvusClientException

    This exception will be raised when any error occurs during this operation.

Example

import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.collection.request.RenameCollectionReq;

// 1. Set up a client
ConnectConfig connectConfig = ConnectConfig.builder()
.uri("YOUR_CLUSTER_ENDPOINT")
.token("YOUR_CLUSTER_TOKEN")
.build();

MilvusClientV2 client = new MilvusClientV2(connectConfig);

// 2. Rename collection "test" to "test2"
RenameCollectionReq renameCollectionReq = RenameCollectionReq.builder()
.collectionName("test")
.newCollectionName("test2")
.build();
client.renameCollection(renameCollectionReq);