SWAPDB
Syntax
SWAPDB index1 index2
Module
connectionCategories
connection dangerous keyspace slowDescription
This command swaps two databases, so that immediately all the clients connected to a given database will see the data of the other database, and the other way around. If either one of the databases does not exist, it will be created.
Examples
- Go (Embedded)
- CLI
Swap the databases with indexes 1 and 2:
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
err := db.SwapDBs(1, 2)
The method above only switches the databases for the currently active TCP connections.
To switch the database for the embedded instance, use the SelectDB
method.
Swap the databases with indexes 1 and 2:
> SWAPDB 1 2