SELECT
Syntax
SELECT index
Module
connectionCategories
connection fastDescription
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
- Go (Embedded)
- CLI
Select the database that the embedded instance is operating from:
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
err := db.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.
Select the database with index 1:
> SELECT 1