Skip to content
API Reference Zilliz Cloud Milvus Attu

Database Operations

Milvus supports multiple databases, allowing you to organize collections into logical groups. This guide covers all database operations.

Create a new database:

await client.createDatabase({
db_name: 'my_database',
});

Create a database with properties:

await client.createDatabase({
db_name: 'my_database',
properties: {
owner: 'analytics-team',
environment: 'production',
},
});

List all databases:

const result = await client.listDatabases();
console.log('Databases:', result.db_names);
// Output: ['default', 'my_database']

Get detailed information about a database:

const result = await client.describeDatabase({
db_name: 'my_database',
});
console.log('Database info:', result);

Modify database properties:

await client.alterDatabaseProperties({
db_name: 'my_database',
properties: {
owner: 'search-team',
environment: 'staging',
},
});

Remove specific properties from a database:

await client.dropDatabaseProperties({
db_name: 'my_database',
properties: ['environment'],
});

Delete a database (all collections in the database will be deleted):

await client.dropDatabase({
db_name: 'my_database',
});

When creating a client, specify the database:

const client = new MilvusClient({
address: 'localhost:19530',
database: 'my_database', // Set default database
});

Create separate clients for different databases:

const db1Client = new MilvusClient({
address: 'localhost:19530',
database: 'database1',
});
const db2Client = new MilvusClient({
address: 'localhost:19530',
database: 'database2',
});
// Use db1Client for database1 operations
await db1Client.createCollection({
/* ... */
});
// Use db2Client for database2 operations
await db2Client.createCollection({
/* ... */
});

Each database is isolated:

  • Collections in different databases are completely separate
  • Operations on one database don’t affect others
  • Users and roles can have different permissions per database
  1. Use databases for logical separation: Organize collections by application, environment, or team
  2. Default database: The default database is created automatically
  3. Database naming: Use descriptive names that reflect the purpose
  4. Permissions: Configure user permissions at the database level for security