清空 Orient-DB 中的所有行

Empty all the rows in Orient-DB

Orient-DB 中是否有 flush/empty 所有 classes/clusters 的命令。

喜欢 MySQL 中的 Empty 函数。

P.S :也在此处搜索:https://github.com/orientechnologies/orientdb/wiki/Console-Commands

没有可用的命令。

如果要保留classes 的元数据,可以使用truncate 命令(与大多数RDBMS 相同)。它从指定 class 的所有集群中删除所有记录(但保留有关 class 的元数据):

truncate class <yourclass>

如果你想截断所有 custom classes(所以不包括 OrientDB classes,它们都以大写 "O" ), 你可以使用这个脚本:

  connect plocal:<yoururl> <yourusername> <yourpassword>;
  js var result = db.query('select name from (select expand(classes) from metadata:schema) where name.charAt(0) <> "O"'); 
  for (var i = 0; i < result.length; i++) { 
    var className = result[i].getRecord().field('name'); 
    db.command('truncate class ' + className);
  }; 
  result.length + ' classes truncated'; 
  end;
  exit

将此脚本另存为 truncate-all.osql。 要执行此脚本,请转到 ORIENTDB_HOME/bin 目录并执行:

$ ./console.sh truncate-all.osql