# How to delete a single node

**URL:** <https://discuss.dgraph.io/t/how-to-delete-a-single-node/18651>\
**Category:** Dgraph\
**Created:** [May 20, 2023, 1:41am UTC](https://discuss.dgraph.io/t/how-to-delete-a-single-node/18651 "2023-05-20T01:41:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![valley](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/valley/32/10426_2.png) [@valley](https://discuss.dgraph.io/u/valley)\
**Post date:** [May 20, 2023, 1:41am UTC](https://discuss.dgraph.io/t/how-to-delete-a-single-node/18651/1 "2023-05-20T01:41:22Z")

</div>

Hi,  
I just started learning Dgraph. I have an extremally simple question: how to delete a single node itself (not its affiliation with any other node)? Suppose I have  
{  
“uid”: “0x1”,  
“name”: “Ben”  
},  
that is not connected to any other node - how to delete it?  
I’ll tried something obvious  
{  
“delete”: [  
{  
“uid”: “0x1”  
}  
]  
}  
but that deletes connections to other nodes only, the node itself is still there. Despite the question simplicity, I couldn’t find any answer so far.  
Thanks…

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [May 20, 2023, 1:30pm UTC](https://discuss.dgraph.io/t/how-to-delete-a-single-node/18651/2 "2023-05-20T13:30:23Z")

</div>

I was thinking there was more docs around DQL delete, but this is all I really see:

> **[Upsert - Dgraph](https://docs.hypermode.com/dgraph/dql/upsert#uid-function-in-upsert)**

Looking back over a [past discussion](http://discuss.hypermode.com/t/deletejson-to-delete-a-node-does-not-delete-it/12809/4), I linked to a [doc page](https://dgraph.io/docs/mutations/json-mutation-format/#deleting-edges) that doesn’t seem to exist anymore. @MichelDiz do you know if this got moved somewhere? Would be worth a 301 at least please.

So in leue of not having that doc page I was looking for, let me try to briefly explain it here again.

Deletes in DQL work with three patterns (somewhat explained in the [DQL Tour](https://dgraph.io/tour/schema/8/)). You can delete a specific Subject-Predicate-Object (`SPO`), or delete all Subject-Predicate no matter the Object value assigned (`SP*`), or delete all predicates of a given Subject (`S**`).

In DQL these take the form of:

```auto
delete {
  # SPO
  <0x1> <name> "Ben" .
  # SP*
  <0x1> <name> * .
  # S**
  <0x1> * * .
}

```

In JSON format:

```json
{
  delete: [
    // SPO
    {
      "uid": "0x1",
      "name": "Ben"
    },
    // SP*
    {
      "uid": "0x1",
      "name": null
    },
    // S**
    {
      "uid": "0x1"
    }
  ]
}

```

Now a kicker with using the `S**` method, is that this only works to delete all predicates of the associated type (`dgraph.type`). If your node does not have a type, then the `S**` method practically does nothing. I am not sure give your berevity of context, if you are using types or not.

And then another thing to know, is that a `uid` itself is not stored without a predicate or object. So if you query looking to see if the `uid` exists after you delete everything, it will always exist. Here is some more explanation around this concept:

> [@Why is it that if I delete a node in Ratel, I can still query for it?](http://discuss.hypermode.com/t/why-is-it-that-if-i-delete-a-node-in-ratel-i-can-still-query-for-it/17828/3):
>
> This is an old situation that comes and goes again and again. Dgraph does not delete system UIDs. Because it is a fixed range, a fixed length address. It expands and there is no way to delete addresses or “jump”. It’s like a RAM(virtual?) memory that allocates more addresses to be used. Previous addresses cannot be deleted. It is also comparable to Blockchain(in a very abstract way), you cannot erase previous blocks(prune). So by design these addresses will exist until the end of the DB’s life. …

> [@Querying an arbitrary UID always returns a result](http://discuss.hypermode.com/t/querying-an-arbitrary-uid-always-returns-a-result/16503/2):
>
> This is probably my favorite thing that when really understood goes a long way in understanding how Dgraph actually works. Fun fact, a uid never exists and always exists at the same time in Dgraph As you discovered above it always exists, but in the database it never exists. Proof of this concept is that if you do this mutation assuming you have no data on uid 0x2a (pick any other non-used uid for this): set { uid("0x2a") \<dgraph.type\> "example" . uid("0x2a") \<name\> "Foo" . uid("0x2a"…

---

<div class="post-metadata">

**Author:** ![valley](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/valley/32/10426_2.png) [@valley](https://discuss.dgraph.io/u/valley)\
**Post date:** [May 20, 2023, 4:21pm UTC](https://discuss.dgraph.io/t/how-to-delete-a-single-node/18651/3 "2023-05-20T16:21:08Z")

</div>

Hey Anthony, thank you so much for the clarification!
