Redis MOVE – How to move key from one to another database in redis

5 years ago Lalit Bhagtani 0

In this tutorial, we will learn about how to move a key from one database to another database in redis datastore. For this we will use a COMMAND – MOVE in redis-cli.

This command is used to remove the specified key from a currently selected database and insert the same key into a destination database. If key does not exists in the source database or it is already exist in the destination database, then no operation is performed and 0 is returned. The syntax of redis MOVE command is as follows :-

Syntax :-

redis host:post> MOVE <key> <destination database>

Output :- 

- 1, if key is moved from source database to destination database.
- 0, if key is not moved.

Example :-

Redis MOVE

References :-

  1. MOVE Command Docs

That’s all for how to move a key from one database to another database in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.