Empty all the rows in Orient-DB Empty all the rows in Orient-DB database database

Empty all the rows in Orient-DB


There is no such command available.

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>

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

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

$ ./console.sh truncate-all.osql