Database in Serving Clusters
This feature is available only with the Enterprise plan or higher.
A database in a serving cluster is a logical container for collections hosted by a Dedicated serving cluster. Use this page to create, view, configure, use, and drop databases through a serving cluster endpoint.
This page is for databases in serving clusters. For project-level databases queried with on-demand compute, see Database for On-Demand Search. For a comparison of database models, see Database Explained.
Before you begin
Ensure that:
-
You have created a Dedicated serving cluster.
-
You have the serving cluster endpoint, for example
https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530. -
You have an authentication token. This can be an API key with access to the target cluster or a cluster credential in
username:passwordformat. -
You have Organization Owner or Project Admin access to manage databases.
When a Dedicated cluster is created, a default database is created automatically. You can create up to 1,024 databases in a Dedicated cluster.
Create database
You can create a database from the Zilliz Cloud console or programmatically.
- Python
- Java
- Go
- NodeJS
- cURL
from pymilvus import MilvusClient
client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN",
)
client.create_database(
db_name="my_database_1",
)
import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.database.request.CreateDatabaseReq;
ConnectConfig config = ConnectConfig.builder()
.uri("YOUR_CLUSTER_ENDPOINT")
.token("YOUR_CLUSTER_TOKEN")
.build();
MilvusClientV2 client = new MilvusClientV2(config);
CreateDatabaseReq request = CreateDatabaseReq.builder()
.databaseName("my_database_1")
.build();
client.createDatabase(request);
client, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: "YOUR_CLUSTER_ENDPOINT",
APIKey: "YOUR_CLUSTER_TOKEN",
})
if err != nil {
// handle error
}
err = client.CreateDatabase(ctx, milvusclient.NewCreateDatabaseOption("my_database_1"))
if err != nil {
// handle error
}
import { MilvusClient } from "@zilliz/milvus2-sdk-node";
const client = new MilvusClient({
address: "YOUR_CLUSTER_ENDPOINT",
token: "YOUR_CLUSTER_TOKEN",
});
await client.createDatabase({
db_name: "my_database_1",
});
curl --request POST \
--url "YOUR_CLUSTER_ENDPOINT/v2/vectordb/databases/create" \
--header "Authorization: Bearer YOUR_CLUSTER_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dbName": "my_database_1"
}'
You can also set properties when creating a database. The following example sets the number of replicas.
- Python
- Java
- Go
- NodeJS
- cURL
client.create_database(
db_name="my_database_2",
properties={
"database.replica.number": 3,
},
)
import java.util.HashMap;
import java.util.Map;
Map<String, String> properties = new HashMap<>();
properties.put("database.replica.number", "3");
CreateDatabaseReq request = CreateDatabaseReq.builder()
.databaseName("my_database_2")
.properties(properties)
.build();
client.createDatabase(request);
err = client.CreateDatabase(
ctx,
milvusclient.NewCreateDatabaseOption("my_database_2").
WithProperty("database.replica.number", 3),
)
if err != nil {
// handle error
}
await client.createDatabase({
db_name: "my_database_2",
properties: {
"database.replica.number": 3,
},
});
curl --request POST \
--url "YOUR_CLUSTER_ENDPOINT/v2/vectordb/databases/create" \
--header "Authorization: Bearer YOUR_CLUSTER_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dbName": "my_database_2",
"properties": {
"database.replica.number": 3
}
}'
View databases
List databases or describe a specific database.
- Python
- Java
- Go
- NodeJS
- cURL
databases = client.list_databases()
print(databases)
database = client.describe_database(
db_name="default",
)
print(database)
import io.milvus.v2.service.database.request.DescribeDatabaseReq;
import io.milvus.v2.service.database.response.DescribeDatabaseResp;
import io.milvus.v2.service.database.response.ListDatabasesResp;
ListDatabasesResp databases = client.listDatabases();
DescribeDatabaseResp database = client.describeDatabase(
DescribeDatabaseReq.builder()
.databaseName("default")
.build()
);
databases, err := client.ListDatabase(ctx, milvusclient.NewListDatabaseOption())
if err != nil {
// handle error
}
log.Println(databases)
database, err := client.DescribeDatabase(ctx, milvusclient.NewDescribeDatabaseOption("default"))
if err != nil {
// handle error
}
log.Println(database)
const databases = await client.listDatabases();
console.log(databases);
const database = await client.describeDatabase({
db_name: "default",
});
console.log(database);
curl --request POST \
--url "YOUR_CLUSTER_ENDPOINT/v2/vectordb/databases/describe" \
--header "Authorization: Bearer YOUR_CLUSTER_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dbName": "default"
}'
Manage database properties
The following database properties can be configured for databases in serving clusters.
| Property | Description |
|---|---|
database.replica.number | The number of replicas for the database. |
database.max.collections | The maximum number of collections allowed in the database. |
database.force.deny.writing | Whether to deny write operations for the database. |
database.force.deny.reading | Whether to deny read operations for the database. |
Alter database properties
The following example limits the number of collections that can be created in a database.
- Python
- Java
- Go
- NodeJS
- cURL
client.alter_database_properties(
db_name="my_database_1",
properties={
"database.max.collections": 10,
},
)
import io.milvus.v2.service.database.request.AlterDatabasePropertiesReq;
client.alterDatabaseProperties(
AlterDatabasePropertiesReq.builder()
.databaseName("my_database_1")
.property("database.max.collections", "10")
.build()
);
err = client.AlterDatabaseProperties(
ctx,
milvusclient.NewAlterDatabasePropertiesOption("my_database_1").
WithProperty("database.max.collections", 10),
)
if err != nil {
// handle error
}
await client.alterDatabaseProperties({
db_name: "my_database_1",
properties: {
"database.max.collections": 10,
},
});
curl --request POST \
--url "YOUR_CLUSTER_ENDPOINT/v2/vectordb/databases/alter" \
--header "Authorization: Bearer YOUR_CLUSTER_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dbName": "my_database_1",
"properties": {
"database.max.collections": 10
}
}'
Drop database properties
The following example removes the collection limit from a database.
- Python
- Java
- Go
- NodeJS
- cURL
client.drop_database_properties(
db_name="my_database_1",
property_keys=[
"database.max.collections",
],
)
import io.milvus.v2.service.database.request.DropDatabasePropertiesReq;
import java.util.Collections;
client.dropDatabaseProperties(
DropDatabasePropertiesReq.builder()
.databaseName("my_database_1")
.propertyKeys(Collections.singletonList("database.max.collections"))
.build()
);
err = client.DropDatabaseProperties(
ctx,
milvusclient.NewDropDatabasePropertiesOption("my_database_1", "database.max.collections"),
)
if err != nil {
// handle error
}
await client.dropDatabaseProperties({
db_name: "my_database_1",
property_keys: ["database.max.collections"],
});
curl --request POST \
--url "YOUR_CLUSTER_ENDPOINT/v2/vectordb/databases/alter" \
--header "Authorization: Bearer YOUR_CLUSTER_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dbName": "my_database_1",
"propertyKeys": [
"database.max.collections"
]
}'
Use database
You can switch from one database to another without reconnecting when using an SDK.
RESTful API does not support switching databases on a persistent connection. For RESTful API requests, specify the target database in each request body when the operation supports dbName.
- Python
- Java
- Go
- NodeJS
- cURL
client.use_database(
db_name="my_database_2",
)
client.useDatabase("my_database_2");
err = client.UseDatabase(ctx, milvusclient.NewUseDatabaseOption("my_database_2"))
if err != nil {
// handle error
}
await client.useDatabase({
db_name: "my_database_2",
});
# RESTful API does not provide a persistent connection to switch.
# Specify "dbName" in the request body of each operation when supported.
Drop database
Default databases cannot be dropped. Before dropping a database, drop all collections in the database first.
- Python
- Java
- Go
- NodeJS
- cURL
client.drop_database(
db_name="my_database_2",
)
import io.milvus.v2.service.database.request.DropDatabaseReq;
client.dropDatabase(
DropDatabaseReq.builder()
.databaseName("my_database_2")
.build()
);
err = client.DropDatabase(ctx, milvusclient.NewDropDatabaseOption("my_database_2"))
if err != nil {
// handle error
}
await client.dropDatabase({
db_name: "my_database_2",
});
curl --request POST \
--url "YOUR_CLUSTER_ENDPOINT/v2/vectordb/databases/drop" \
--header "Authorization: Bearer YOUR_CLUSTER_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dbName": "my_database_2"
}'