清除OrientDB数据库
给定一个com.orientechnologies.orient.core.db.ODatabase<T>
对象,清除数据库(删除每个对象,但尊重现有模式)的最佳程序化方法(不使用sql,无控制台脚本)是什么?清除OrientDB数据库
基于Alessandro的评论和rmuller对this question的回答,我已经构建了一个java helper方法。
db.getMetadata().getSchema().getClasses().stream()
.filter(oClass -> !oClass.getName().startsWith(ORIENTDB_CLASS_PREFIX)) //
.forEach(oClass -> {
try {
oClass.truncate();
} catch (IOException e) {
LOGGER.warn("Not possible to truncate class " + oClass.getName(), e);
}
});
什么是ORIENTDB_CLASS_PREFIX? – Shashank
private static final String ORIENTDB_CLASS_PREFIX =“O”; – diegomtassis
如果图表无法正常工作,请帮助 – Shashank
你可以看看这个类似的问题http://stackoverflow.com/questions/28134059/empty-all-the-rows-in-orient-db。希望能帮助到你。 –