Database Operations
Milvus supports multiple databases, allowing you to organize collections into logical groups. This guide covers all database operations.
Creating a Database
Section titled “Creating a Database”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', },});Listing Databases
Section titled “Listing Databases”List all databases:
const result = await client.listDatabases();
console.log('Databases:', result.db_names);// Output: ['default', 'my_database']Describing a Database
Section titled “Describing a Database”Get detailed information about a database:
const result = await client.describeDatabase({ db_name: 'my_database',});
console.log('Database info:', result);Altering Database Properties
Section titled “Altering Database Properties”Modify database properties:
await client.alterDatabaseProperties({ db_name: 'my_database', properties: { owner: 'search-team', environment: 'staging', },});Dropping Database Properties
Section titled “Dropping Database Properties”Remove specific properties from a database:
await client.dropDatabaseProperties({ db_name: 'my_database', properties: ['environment'],});Dropping a Database
Section titled “Dropping a Database”Delete a database (all collections in the database will be deleted):
await client.dropDatabase({ db_name: 'my_database',});Multi-Database Usage Patterns
Section titled “Multi-Database Usage Patterns”Switching Between Databases
Section titled “Switching Between Databases”When creating a client, specify the database:
const client = new MilvusClient({ address: 'localhost:19530', database: 'my_database', // Set default database});Working with Multiple Databases
Section titled “Working with Multiple Databases”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 operationsawait db1Client.createCollection({ /* ... */});
// Use db2Client for database2 operationsawait db2Client.createCollection({ /* ... */});Database Isolation
Section titled “Database Isolation”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
Best Practices
Section titled “Best Practices”- Use databases for logical separation: Organize collections by application, environment, or team
- Default database: The
defaultdatabase is created automatically - Database naming: Use descriptive names that reflect the purpose
- Permissions: Configure user permissions at the database level for security
Next Steps
Section titled “Next Steps”- Learn about Collection Management
- Explore User & Role Management