Search code examples
orientdb

How to delete a record when only @RID is known


I'd like to retrieve the class name of a given @RID so I can delete the record. I don't know its class name or wether it's a vertex, an edge or something else. How to do it via SQL or the Java API(both would be equally fine)?


Solution

  • Via SQL you can use

    select @class from @Rid
    

    enter image description here

    Java

    OrientGraph g=new OrientGraph(yourPath); 
    String _class= g.getElement(new ORecordId(9,0)).getProperty("@class");
    

    Delete record:

    Sql

    delete from 9:0 unsafe
    

    you can see http://orientdb.com/docs/2.1/SQL-Delete.html

    Java

    g.getRawGraph().getRecord(new ORecordId(9,0)).delete();