Redis Select command
Redis Select command is used to switch to the specified database, the database index number index specified with the numeric value to 0 as the starting index value.
grammar
redis Select basic command syntax is as follows:
redis 127.0.0.1:6379> SELECT index
Available versions
> = 1.0.0
return value
Always returns OK.
Examples
redis 127.0.0.1:6379> SET db_number 0 # 默认使用 0 号数据库 OK redis 127.0.0.1:6379> SELECT 1 # 使用 1 号数据库 OK redis 127.0.0.1:6379[1]> GET db_number # 已经切换到 1 号数据库,注意 Redis 现在的命令提示符多了个 [1] (nil) redis 127.0.0.1:6379[1]> SET db_number 1 OK redis 127.0.0.1:6379[1]> GET db_number "1" redis 127.0.0.1:6379[1]> SELECT 3 # 再切换到 3 号数据库 OK redis 127.0.0.1:6379[3]> # 提示符从 [1] 改变成了 [3]