# HMSET

> Set several hash fields and reply OK (older form of HSET).

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

```
HMSET key field value [field value ...]
```

- Group: Hash
- Complexity: O(N) where N is the number of fields being set
- HotKV Cloud: all plans
- On-Premise: no license needed
- Deprecated: use HSET instead

`HMSET` writes each `field` and `value` pair into the hash at `key`, creating
the hash if needed. It behaves exactly like [HSET](https://docs.hotkv.com/commands/hset/index.md) (including
removing the time to live of each field it overwrites), except that it replies
`OK` instead of the number of new fields. New code should use `HSET`, which
accepts several pairs too.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Simple string `OK` | Simple string `OK` |

Errors:

- `WRONGTYPE` if `key` holds a value that is not a hash.
- ``ERR wrong number of arguments for 'hmset' command`` if no pair is given or
  a field has no value.

## Examples

```
127.0.0.1:6379> HMSET user:1 name "Ada" lang "en"
OK
127.0.0.1:6379> HGET user:1 lang
"en"
```

## Compatibility

Same as Redis 7.4 and Valkey 8, where it is also deprecated in favour of
`HSET`.

## See also

[HSET](https://docs.hotkv.com/commands/hset/index.md), [HMGET](https://docs.hotkv.com/commands/hmget/index.md), [HSETEX](https://docs.hotkv.com/commands/hsetex/index.md)