Rename a Collection
If you want to rename a collection, you can use the collection-renaming API to interact with Milvus. This guide helps you understand how to rename an existing collection using the SDK of your choice.
In the following code snippet, we create a collection and name it old_collection
. Then we rename it new_collection
.
from pymilvus import Collection, utility
collection = Collection(name="old_collection", schema=schema)
utility.rename_collection("old_collection", "new_collection")
import io.milvus.client.*;
import io.milvus.param.*;
RenameCollectionParam renameCollectionParam = new RenameCollectionParam.newBuilder()
.withOldCollectionName("old_collection")
.withNewCollectionName("new_collection")
.build();
milvusClient.renameCollection(renameCollectionParam);
// Not available yet
const { MilvusClient } = require('@zilliz/milvus2-sdk-node');
const client = new MilvusClient({ address, username, password });
client.renameCollection({
collection_name: "old_collection",
new_collection_name: "new_collection"
}).then(res => {
console.log(res);
})
using Milvus.Client;
var collection = milvusClient.GetCollection("old_collection").RenameAsync("new_collection");
For code examples in the flavor of other programming languages, keep watching.