清空Orient-DB中的所有行 [英] Empty all the rows in Orient-DB

查看:155
本文介绍了清空Orient-DB中的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有命令刷新/清空Orient-DB中的所有类/集群。

Is there are a command to flush/empty all the classes/clusters in Orient-DB.

像MySQL中的Empty函数。

Like Empty function in MySQL.

PS:在此处搜索: https:// github。 com / orientechnologies / orientdb / wiki / Console-Commands

P.S : Searched here as well : https://github.com/orientechnologies/orientdb/wiki/Console-Commands

推荐答案

没有这样的命令可用。

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

If you want to preserve the meta data of the classes, you can use the truncate command (same as most RDBMS). It deletes all records from all clusters of the specified class (but keeps the meta data about the class):

truncate class <yourclass>

如果您要截断所有自定义类,所有都以大写O开头),你可以使用这个脚本:

If you want to truncate all custom classes (so excluding the OrientDB classes, which all start with capital "O"), you can use this script:

  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 目录并执行:

Save this script as truncate-all.osql. To execute this script, go to ORIENTDB_HOME/bin directory and execute:

$ ./console.sh truncate-all.osql

这篇关于清空Orient-DB中的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆