Is there are a command to flush/empty all the classes/clusters in Orient-DB.
Like Empty function in MySQL.
P.S : Searched here as well : https://github.com/orientechnologies/orientdb/wiki/Console-Commands
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With