Rajith Gun Hewage
Rajith Gun Hewage

Reputation: 532

How to avoid duplicate inserts for an OrientDB database?

In SQL there's a query INSERT IGNORE which keeps duplicate entries out of the database based on the primary key. But is there a way to achieve this functionality in OrientDB since the primary key concept here is kind of achieved using the @rid concept?

Upvotes: 0

Views: 675

Answers (2)

Lvca
Lvca

Reputation: 9060

Have you tried the UPSERT?

UPDATE Profile SET nick = 'Luca' UPSERT WHERE nick = 'Luca'

Please create an index against "nick" property.

Upvotes: 1

Alessandro Rota
Alessandro Rota

Reputation: 3570

I think you can use a unique index on that class, so you can avoid duplicate entries.

Upvotes: 1

Related Questions