Skip to main content

SELECT

Syntax

SELECT index

Module

connection

Categories

connection fast

Description

Change the logical database that the current connection is operating from. If the database does not exist, it will be created. When this command is executed in a RAFT cluster, the database will be created in all the nodes of the cluster.

Examples

Select the database that the embedded instance is operating from:

vault, err := echovault.NewEchoVault()
if err != nil {
log.Fatal(err)
}
err := vault.SelectDB(2)

After successfully calling this method, all subsequent commands executed on that instance will be executed on the selected database. So you should to be careful when doing this in a multi-threaded environment.