# MOVE

> Move a key from the selected database to another database.

URL: https://docs.hotkv.com/commands/move/

```
MOVE key db
```

- Group: Keys
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`MOVE` takes `key` out of the selected database and puts it in database `db`,
with its time to live. Nothing happens when the key does not exist in the
source or already exists in the target.

`MOVE` is not available on a cluster node with the default `cluster-databases 1`.
With `cluster-databases` above 1, `MOVE` works between the node's databases (the
key keeps its slot). See
[Databases in a cluster](https://docs.hotkv.com/clustering/keys-and-commands/index.md#databases).

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Moved | Integer `1` | Integer `1` |
| The key is missing, or the target already has a key with that name | Integer `0` | Integer `0` |

Errors:

- `ERR source and destination objects are the same` when `db` is the
  selected database.
- `ERR DB index is out of range` for a database that does not exist.
- `ERR MOVE is not allowed in cluster mode` on a cluster node whose
  `cluster-databases` is 1.

## Examples

```
127.0.0.1:6379> SET job:42 "pending"
OK
127.0.0.1:6379> MOVE job:42 1
(integer) 1
127.0.0.1:6379> EXISTS job:42
(integer) 0
127.0.0.1:6379> SELECT 1
OK
127.0.0.1:6379[1]> GET job:42
"pending"
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[COPY](https://docs.hotkv.com/commands/copy/index.md), [RENAME](https://docs.hotkv.com/commands/rename/index.md),
[SELECT](https://docs.hotkv.com/commands/select/index.md)