Clear all rows in Orient-DB

Is there a command to reset / delete all classes / clusters in Orient-DB.

Like an empty function in MySQL.

PS: Search here: https://github.com/orientechnologies/orientdb/wiki/Console-Commands

+4
source share
1 answer

There is no such team.

If you want to save class metadata, you can use the command truncate(just like most RDBMSs). It deletes all records from all clusters of the specified class (but saves metadata about the class):

truncate class <yourclass>

( OrientDB, "O" ), 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

script truncate-all.osql. script, ORIENTDB_HOME/bin :

$ ./console.sh truncate-all.osql
+6

All Articles