跳到主要内容
版本:v2.5.x

CreateDatabase()

This method creates a database.

Go
func (c *Client) CreateDatabase(ctx context.Context, option CreateDatabaseOption, callOptions ...grpc.CallOption) error

Request Parameters​

Parameter

Description

Type

ctx

Context for the current call to work.

context.Context

option

Optional parameters of the methods.

CreateDatabaseOption

callOpts

Optional parameters for calling the methods.

grpc.CallOption

CreateDatabaseOption​

This is an interface type. The createDatabaseOption struct type implements this interface type.

You can use the NewCreateDatabaseOption() function to get the concrete implementation.

NewCreateDatabaseOption​

The signature of this method is as follows:

Go
func NewCreateDatabaseOption(dbName string) *createDatabaseOption

Parameter

Description

Type

dbName

Name of the database to create.

string

Return​

Null

Example​

Text
dbName := `test_db`
cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: milvusAddr,
})
if err != nil {
// handle err
}

err = cli.CreateDatabase(ctx, milvusclient.NewCreateDatabaseOption(dbName))
if err != nil {
// handle err
}