---
title: "HDEL"
url: "https://docs.yugabyte.com/stable/yedis/api/hdel/"
---

# HDEL

## Synopsis

**`HDEL key field [field ...]`**

This command removes the given `fields` from the hash that is associated with the given `key`.

- If the given `key` does not exist, it is characterized as an empty hash, and 0 is returned for no elements are removed.
- If the given `key` is associated with non-hash data, an error is raised.

## Return value

Depends on the configuration parameter `emulate_redis_responses`.

- If `emulate_redis_responses` is `true`, returns the number of existing fields in the hash that were removed by this command.
- If `emulate_redis_responses` is `false`, returns OK.

## Examples

- `emulate_redis_responses` is `true`.
  
  ```sh
  $ HSET yugahash moon "Moon"
  ```
  
  ```
  1
  ```
  
  ```sh
  $ HDEL yugahash moon
  ```
  
  ```
  1
  ```
  
  ```sh
  $ HDEL yugahash moon
  ```
  
  ```
  0
  ```
- `emulate_redis_responses` is `false`.
  
  ```sh
  $ HSET yugahash moon "Moon"
  ```
  
  ```
  "OK"
  ```
  
  ```sh
  $ HDEL yugahash moon
  ```
  
  ```
  "OK"
  ```
  
  ```sh
  $ HDEL yugahash moon
  ```
  
  ```
  "OK"
  ```

## See also

[`hexists`](/stable/yedis/api/hexists/ "hexists"), [`hget`](/stable/yedis/api/hget/ "hget"), [`hgetall`](/stable/yedis/api/hgetall/ "hgetall"), [`hkeys`](/stable/yedis/api/hkeys/ "hkeys"), [`hlen`](/stable/yedis/api/hlen/ "hlen"), [`hmget`](/stable/yedis/api/hmget/ "hmget"), [`hmset`](/stable/yedis/api/hmset/ "hmset"), [`hset`](/stable/yedis/api/hset/ "hset"), [`hincrby`](/stable/yedis/api/hincrby/ "hincrby"), [`hstrlen`](/stable/yedis/api/hstrlen/ "hstrlen"), [`hvals`](/stable/yedis/api/hvals/ "hvals")
