Reputation: 434
After executing DELETE VERTEX v;
to delete all records from an oriendb database, how do I reset the RecordId (@rid) to start over?
I want to run tests so after deleting all records I seed records again; I test a particular record #13:3 but then it changes after the tear down. It is not #13:3 when the db is seeded again.
Upvotes: 2
Views: 184
Reputation: 1418
I have created this simple structure to try your case:
create property V.id integer
create vertex V set id = 1
create vertex V set id = 2
create vertex V set id = 3
create vertex V set id = 4
create vertex V set id = 5
Now the class V has this rids and records:
select from V
----+----+------+----
# |@RID|@CLASS|id
----+----+------+----
0 |#9:0|V |1
1 |#9:1|V |2
2 |#9:2|V |3
3 |#9:3|V |4
4 |#9:4|V |5
----+----+------+----
but if you execute the command
truncate class V unsafe
Truncated 5 record(s) in 0,016000 sec(s).
all records in class V will be deleted (instead of deleting them manually) and the @rids
will be resetted. Now, if you execute a new create vertex V set id = 1
command, the @rid #9:0
will be re-assigned to the first re-inserted record. The following is an example of re-insert:
create vertex V set id = 1
Created vertex 'V#9:0{id:1} v1' in 0,015000 sec(s).
Now, if you query the class V, you'll see the @rid #9:0
re-assigned
select from V
----+----+------+----
# |@RID|@CLASS|id
----+----+------+----
0 |#9:0|V |1
----+----+------+----
Hope it helps
Upvotes: 3