Easy Tutorial
❮ Redis Partitioning Redis Geo ❯

Redis Select Command

Redis Connection

The Redis Select command is used to switch to the specified database. The database index is specified by a numeric value, with 0 being the starting index.

Syntax

The basic syntax for 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.

Example

redis 127.0.0.1:6379> SET db_number 0         # Default using database 0
OK

redis 127.0.0.1:6379> SELECT 1                # Switch to database 1
OK

redis 127.0.0.1:6379[1]> GET db_number        # Switched to database 1, note the command prompt now includes [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             # Switch to database 3
OK

redis 127.0.0.1:6379[3]>                      # The prompt has changed from [1] to [3]

Redis Connection

❮ Redis Partitioning Redis Geo ❯