# How to specify uid in rdf files when using dgraph bulk load?

**URL:** <https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791>\
**Category:** Dgraph\
**Created:** [December 21, 2018, 12:51pm UTC](https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791 "2018-12-21T12:51:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgrdev](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@dgrdev](https://discuss.dgraph.io/u/dgrdev)\
**Post date:** [December 21, 2018, 12:51pm UTC](https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791/1 "2018-12-21T12:51:16Z")

</div>

hello everyone,

when I use test.rdf:

```auto
<0x1> <name> "alpha" .
<0x1> <friend> <0x2> .
<0x2> <name> "beta" .

```

test.schema:

```auto
friend: uid @reverse @count .
name:string @index(term, exact) .

```

use bulk loader:  
` dgraph bulk -r test.rdf -s test.schema`

and I export the database and found that uid changes!!!

curl localhost:8080/admin/export

```auto
<_:uid1> <name> "alpha"^^<xs:string> .
<_:uid2711> <name> "beta"^^<xs:string> .
<_:uid1> <friend> <_:uid2711>

```

Could someone help me? Thanks a lot!!!

---

<div class="post-metadata">

**Author:** ![smantha](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@smantha](https://discuss.dgraph.io/u/smantha)\
**Post date:** [December 21, 2018, 1:13pm UTC](https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791/2 "2018-12-21T13:13:27Z")

</div>

The export data need not contain the uid you have specified.

After import you can verify that the uid are used by doing a query on an uid in ratel.

---

<div class="post-metadata">

**Author:** ![dgrdev](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@dgrdev](https://discuss.dgraph.io/u/dgrdev)\
**Post date:** [December 24, 2018, 6:30am UTC](https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791/3 "2018-12-24T06:30:33Z")

</div>

I tried to query with:

```auto
{
  fd(func: eq(name,"alpha"))
 {
    uid
    name
    friend
   {
     uid
     name
    }
 }
}

```

the result is

```auto
  "data": {
    "fd": [
      {
        "uid": "0x1",
        "name": "alpha",
        "friend": [
          {
            "uid": "0x2711",
            "name": "beta"
          }
        ]
      }
    ]
  }

```

“beta” uid is 0x2711, not 0x2.

---

<div class="post-metadata">

**Author:** ![dmai](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/dmai/32/1254_2.png) [@dmai](https://discuss.dgraph.io/u/dmai)\
**Post date:** [December 24, 2018, 9:53pm UTC](https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791/4 "2018-12-24T21:53:49Z")

</div>

As @smantha said, UIDs are not preserved in the export RDF data. You can use an external ID that you control in your data if you need a persistent ID.

---

<div class="post-metadata">

**Author:** ![dgrdev](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@dgrdev](https://discuss.dgraph.io/u/dgrdev)\
**Post date:** [December 25, 2018, 1:25am UTC](https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791/5 "2018-12-25T01:25:13Z")

</div>

thanks! And I also want to confirm that, dgraph live can specify UID using “assign”, but dgraph bulk cannot, right?

---

<div class="post-metadata">

**Author:** ![pablog](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pablog/32/2426_2.png) [@pablog](https://discuss.dgraph.io/u/pablog)\
**Post date:** [January 12, 2020, 1:00pm UTC](https://discuss.dgraph.io/t/how-to-specify-uid-in-rdf-files-when-using-dgraph-bulk-load/3791/6 "2020-01-12T13:00:00Z")

</div>

> [@dmai](#):
>
> As @smantha said, UIDs are not preserved in the export RDF data. You can use an external ID that you control in your data if you need a persistent ID.

Just for future visits to this thread. As I understand this is not true anymore and exports now preserve UIDs. From Dgraph v1.1.0 release notes:

> Export data contains UID literals instead of blank nodes. Using Live Loader or Bulk Loader to load exported data will result in the same UIDs as the original database. (#3004, #3045) To preserve the previous behavior, set the --new\_uids flag in the live or bulk loader. (1827787)
