Redis Select Command
The Redis SELECT command is used to switch to the specified database. The database index number is specified by a numeric value, with 0 as the starting index.
Syntax
The basic syntax of the redis SELECT command 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]
Other Extensions