检查orientdb中是否存在类 [英] Check if class exists or not in orientdb
本文介绍了检查orientdb中是否存在类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果没有在数据库中退出,如何检查某个类是否存在于db
中我需要创建它并插入记录(如果存在)我需要插入记录。
我需要使用JAVA做同样的事情
How to check if a class exists or not in orient db if it is not exiting in the database i need to create it and insert a record if exists i need to insert the record . I need to do the same using JAVA
推荐答案
您可以通过SQL使用以下语句检索架构信息:
You can retrieve schema information via SQL with the following statement:
select expand(classes) from metadata:schema
特别是要检索单个类:
select from (
select expand(classes) from metadata:schema
) where name = 'YourClassName'
来自Java:
ODatabaseDocumentTx db = ...
if(db.getMetadata().getSchema().existsClass("ClassName")){
...
}
如果你有一个OrientGraph,您可以使用
If you have an OrientGraph, you can get the underlying ODatabaseDocumentTx
with
graph.getRawGraph();
这篇关于检查orientdb中是否存在类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文