You can rename a collection or change its settings. This page focuses on how to modify a collection.
You can rename a collection as follows.
Python
NodeJS
from pymilvus import MilvusClient
client = MilvusClient(
uri="http://localhost:19530",
token="root:Milvus"
client.rename_collection(
old_name="my_collection",
new_name="my_new_collection"
import io.milvus.v2.service.collection.request.RenameCollectionReq;
import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
String CLUSTER_ENDPOINT = "http://localhost:19530";
String TOKEN = "root:Milvus";
ConnectConfig connectConfig = ConnectConfig.builder()
.uri(CLUSTER_ENDPOINT)
.token(TOKEN)
.build();
MilvusClientV2 client = new MilvusClientV2(connectConfig);
RenameCollectionReq renameCollectionReq = RenameCollectionReq.builder()
.collectionName("my_collection")
.newCollectionName("my_new_collection")
.build();
client.renameCollection(renameCollectionReq);
import { MilvusClient, DataType } from "@zilliz/milvus2-sdk-node";
const address = "http://localhost:19530";
const token = "root:Milvus";
const client = new MilvusClient({address, token});
const res = await client.renameCollection({
oldName: "my_collection",
newName: "my_new_collection"
import (
"context"
"fmt"
"github.com/milvus-io/milvus/client/v2/milvusclient"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
milvusAddr := "localhost:19530"
token := "root:Milvus"
client, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: milvusAddr,
APIKey: token,
if err != nil {
fmt.Println(err.Error())
defer client.Close(ctx)
err = client.RenameCollection(ctx, milvusclient.NewRenameCollectionOption("my_collection", "my_new_collection"))
if err != nil {
fmt.Println(err.Error())
export CLUSTER_ENDPOINT="http://localhost:19530"
export TOKEN="root:Milvus"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/rename" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
--header "Request-Timeout: 10" \
-d '{
"collectionName": "my_collection",
"newCollectionName": "my_new_collection"
You can modify collection-level properties after a collection is created.
All the properties listed in this section apply only to managed collections.
The following code snippet demonstrates how to set collection TTL.
Python
NodeJS
from pymilvus import MilvusClient
client.alter_collection_properties(
collection_name="my_collection",
properties={"collection.ttl.seconds": 60}
import io.milvus.param.Constant;
import io.milvus.v2.service.collection.request.AlterCollectionPropertiesReq;
AlterCollectionPropertiesReq alterCollectionReq = AlterCollectionPropertiesReq.builder()
.collectionName("my_collection")
.property(Constant.TTL_SECONDS, "60")
.build();
client.alterCollectionProperties(alterCollectionReq);
res = await client.alterCollection({
collection_name: "my_collection",
properties: {
"collection.ttl.seconds": 60
err = client.AlterCollectionProperties(ctx, milvusclient.NewAlterCollectionPropertiesOption("my_collection").WithProperty(common.CollectionTTLConfigKey, 60))
if err != nil {
fmt.Println(err.Error())
export CLUSTER_ENDPOINT="http://localhost:19530"
export TOKEN="root:Milvus"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/alter_properties" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
--header "Request-Timeout: 10" \
-d '{
"collectionName": "my_collection",
"properties": {
"collection.ttl.seconds": 60
The following code snippet designates an existing TIMESTAMPTZ field (expire_at) as the TTL field for entity-level TTL. The collection must already contain a TIMESTAMPTZ field with that name, and collection.ttl.seconds must not be set — the two TTL modes are mutually exclusive.
For the full entity-level TTL workflow (schema setup, insert, query, refresh, drop), refer to Set entity-level TTL.
Python
NodeJS
from pymilvus import MilvusClient
client.alter_collection_properties(
collection_name="my_collection",
properties={"ttl_field": "expire_at"}
The following code snippet demonstrates how to enable mmap.
Python
NodeJS
from pymilvus import MilvusClient
client.alter_collection_properties(
collection_name="my_collection",
properties={"mmap.enabled": True}
AlterCollectionPropertiesReq alterCollectionReq = AlterCollectionPropertiesReq.builder()
.collectionName("my_collection")
.property(Constant.MMAP_ENABLED, "True")
.build();
client.alterCollectionProperties(alterCollectionReq);
await client.alterCollectionProperties({
collection_name: "my_collection",
properties: {
"mmap.enabled": true
err = client.AlterCollectionProperties(ctx, milvusclient.NewAlterCollectionPropertiesOption("my_collection").WithProperty(common.MmapEnabledKey, true))
if err != nil {
fmt.Println(err.Error())
curl -X POST "http://localhost:19530/v2/vectordb/collections/alter_properties" \
-H "Content-Type: application/json" \
-H "Request-Timeout: 10" \
-d '{
"collectionName": "my_collection",
"properties": {
"mmap.enabled": "true"
The following code snippet demonstrates how to enable the partition key.
Python
NodeJS
from pymilvus import MilvusClient
client.alter_collection_properties(
collection_name="my_collection",
properties={"partitionkey.isolation": True}
AlterCollectionPropertiesReq alterCollectionReq = AlterCollectionPropertiesReq.builder()
.collectionName("my_collection")
.property("partitionkey.isolation", "True")
.build();
client.alterCollectionProperties(alterCollectionReq);
await client.alterCollectionProperties({
collection_name: "my_collection",
properties: {
"partitionkey.isolation": true
err = client.AlterCollectionProperties(ctx, milvusclient.NewAlterCollectionPropertiesOption("my_collection").WithProperty(common.PartitionKeyIsolationKey, true))
if err != nil {
fmt.Println(err.Error())
curl -X POST "http://localhost:19530/v2/vectordb/collections/alter_properties" \
-H "Content-Type: application/json" \
-H "Request-Timeout: 10" \
-H "Authorization: Bearer <token>" \
-d '{
"collectionName": "my_collection",
"properties": {
"partitionkey.isolation": "true"
The following code snippet demonstrates how to enable the dynamic field.
Python
NodeJS
from pymilvus import MilvusClient
client.alter_collection_properties(
collection_name="my_collection",
properties={"dynamicfield.enabled": True}
AlterCollectionPropertiesReq alterCollectionReq = AlterCollectionPropertiesReq.builder()
.collectionName("my_collection")
.property("dynamicfield.enabled", "True")
.build();
client.alterCollectionProperties(alterCollectionReq);
await client.alterCollectionProperties({
collection_name: "my_collection",
properties: {
"dynamicfield.enabled": true
err = client.AlterCollectionProperties(ctx, milvusclient.NewAlterCollectionPropertiesOption("my_collection").WithProperty(common.EnableDynamicSchemaKey, true))
if err != nil {
fmt.Println(err.Error())
curl -X POST "http://localhost:19530/v2/vectordb/collections/alter_properties" \
-H "Content-Type: application/json" \
-H "Request-Timeout: 10" \
-H "Authorization: Bearer <token>" \
-d '{
"collectionName": "my_collection",
"properties": {
"dynamicfield.enabled": "true"
The allow_insert_auto_id property allows a collection with AutoID enabled to accept user-provided primary key values during insert, upsert, and bulk import. When set to “true”, Milvus uses the user-provided primary key value if present; otherwise it auto-generates. Default is “false”.
The example below shows how to enable allow_insert_auto_id:
Python
NodeJS
client.alter_collection_properties(
collection_name="my_collection",
properties={"allow_insert_auto_id": "true"}
AlterCollectionPropertiesReq alterCollectionReq = AlterCollectionPropertiesReq.builder()
.collectionName("my_collection")
.property("allow_insert_auto_id", "True")
.build();
client.alterCollectionProperties(alterCollectionReq);
await client.alterCollectionProperties({
collection_name: "my_collection",
properties: {
"allow_insert_auto_id": true
err = client.AlterCollectionProperties(ctx, milvusclient.NewAlterCollectionPropertiesOption("my_collection").WithProperty(common.AllowInsertAutoIDKey, true))
if err != nil {
fmt.Println(err.Error())
curl -X POST "http://localhost:19530/v2/vectordb/collections/alter_properties" \
-H "Content-Type: application/json" \
-H "Request-Timeout: 10" \
-H "Authorization: Bearer <token>" \
-d '{
"collectionName": "my_collection",
"properties": {
"allow_insert_auto_id": "true"
You can set a default time zone for your collection using the timezone property. This determines how time-related data is interpreted and displayed for all operations within the collection, including data insertion, querying, and results presentation.
The value of timezone must be a valid IANA time zone identifier, such as Asia/Shanghai, America/Chicago, or UTC. Using an invalid or non-standard value will result in an error when modifying the collection property.
The example below shows how to set the collection time zone to Asia/Shanghai:
Python
NodeJS
client.alter_collection_properties(
collection_name="my_collection",
properties={"timezone": "Asia/Shanghai"}
AlterCollectionPropertiesReq alterCollectionReq = AlterCollectionPropertiesReq.builder()
.collectionName("my_collection")
.property("timezone", "Asia/Shanghai")
.build();
client.alterCollectionProperties(alterCollectionReq);
err = client.AlterCollectionProperties(ctx, milvusclient.NewAlterCollectionPropertiesOption("my_collection").WithProperty(common.CollectionDefaultTimezone, true))
if err != nil {
fmt.Println(err.Error())
curl -X POST "http://localhost:19530/v2/vectordb/collections/alter_properties" \
-H "Content-Type: application/json" \
-H "Request-Timeout: 10" \
-H "Authorization: Bearer <token>" \
-d '{
"collectionName": "my_collection",
"properties": {
"timezone": "Asia/Shanghai"
You can also reset a collection property by dropping it as follows.
Python
NodeJS
client.drop_collection_properties(
collection_name="my_collection",
property_keys=[
"collection.ttl.seconds"
client.dropCollectionProperties(DropCollectionPropertiesReq.builder()
.collectionName("my_collection")
.propertyKeys(Collections.singletonList("collection.ttl.seconds"))
.build());
client.dropCollectionProperties({
collection_name:"my_collection",
properties: ['collection.ttl.seconds'],
err = client.DropCollectionProperties(ctx, milvusclient.NewDropCollectionPropertiesOption("my_collection", common.CollectionTTLConfigKey))
if err != nil {
fmt.Println(err.Error())
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/drop_properties" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
--header "Request-Timeout: 10" \
-d '{
"collectionName": "my_collection",