2016-06-14 12 views
2

com.orientechnologies.orient.core.db.ODatabase<T>オブジェクトがある場合、データベースを消去するための最良のプログラム方法(SQLはありません、コンソールスクリプトはありません)はどれですか(オブジェクトはすべて削除されますが、既存のスキーマは尊重されます)。OrientDBデータベースを消去

+2

あなたはこの同様の質問http://stackoverflow.com/questions/28134059/empty-all-the-rows-in-orient-dbを見ることができます。それが役に立てば幸い。 –

答えて

1

this questionに対するAlessandroのコメントとrmullerの回答に基づいて、私はJavaヘルパーメソッドを構築しました。

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); 
      } 
    }); 
+0

ORIENTDB_CLASS_PREFIXとは何ですか? – Shashank

+0

プライベートstatic final String ORIENTDB_CLASS_PREFIX = "O"; – diegomtassis

+0

グラフの場合は動作しません。 – Shashank