OrientDB Manual

Console Tool

The OrientDB Console is a Java Application made to work against OrientDB databases and Server instances.

Interactive mode

This is the default mode. Just launch the console by executing the script bin/console.sh (or bin/console.bat in MS Windows systems). Assure to have execution permission on it.

Once started the console is ready to accepts commands.

OrientDB console v.1.6.6 www.orientechnologies.com
Type 'help' to display all the commands supported.

orientdb>

To know all the supported commands look to commands.

Batch mode

To execute commands in batch mode run the bin/console.sh (or bin/console.bat in MS Windows systems) script passing all the commands separated with semicolon ";". Example:

> console.bat "connect remote:localhost/demo;select * from profile"

Or call the console script passing the name of the file in text format containing the list of commands to execute. Commands must be separated with semicolon ";". Example:

orientdb> console.bat commands.txt

In batch mode you can ignore errors to let the script to continue the execution by setting the "ignoreErrors" variable to true:

orientdb> set ignoreErrors true

Enable echo

When you run console commands in pipeline, you could need to display them. Enable "echo" of commands by setting it as property at the beginning:

orientdb> set echo true

Console commands

To know all the commands supported by the Orient console open it and type help or ?.

Command Description
alter class Changes the class schema
alter cluster Changes the cluster attributes
alter database Changes the database attributes
alter property Changes the class's property schema
begin Begins a new transaction
browse class Browses all the records of a class
browse cluster Browses all the records of a cluster
classes Displays all the configured classes
cluster status Displays the status of distributed cluster of servers
clusters Displays all the configured clusters
commit Commits an active transaction
config Displays the configuration where the opened database is located (local or remote)
config get Returns a configuration value
config set Set a configuration value
connect Connects to a database
create class Creates a new class
create cluster Creates a new cluster inside a database
create cluster Creates a new record cluster
create database Creates a new database
create edge Create a new edge connecting two vertices
create index Create a new index
create link Create a link reading a RDBMS JOIN
create vertex Create a new vertex
declare intent Declares an intent
delete Deletes a record from the database using the SQL syntax. To know more about the SQL syntax go here
dictionary keys Displays all the keys in the database dictionary
dictionary get Loookups for a record using the dictionary. If found set it as the current record
dictionary put Inserts or modify an entry in the database dictionary. The entry is composed by key=String, value=record-id
dictionary remove Removes the association in the dictionary
disconnect Disconnects from the current database
display record Displays current record's attributes
display raw record Displays current record's raw format
drop class Drop a class
drop cluster Drop a cluster
drop database Drop a database
drop index Drop an index
drop property Drop a property from a schema class
explain Explain a command by displaying the profiling values while executing it
export database Exports a database
export record Exports a record in any of the supported format (i.e. json)
find references Find the references to a record
freeze database Freezes the database locking all the changes. Use this to raw backup. Once frozen it use the release database to release it
get Returns the value of a property
grant Grants a permission to a user
import database Imports a database previously exported
indexes Displays information about indexes
info Displays information about current status
info class Displays information about a class
insert Inserts a new record in the current database using the SQL syntax. To know more about the SQL syntax go here
js Executes a Javascript in the console
jss Executes a Javascript in the server
list databases List the available databases
load record Loads a record in memory and set it as the current one
profiler Controls the Profiler
properties Returns all the configured properties
pwd Display current path
rebuild index Rebuild an index
Release Database Releases a Console Freeze Database database
reload record Reloads a record in memory and set it as the current one
reload schema Reloads the schema
rollback Rollbacks the active transaction started with begin
select Executes a SQL query against the database and display the results. To know more about the SQL syntax go here
revoke Revokes a permission to a user
set Changes the value of a property
sleep Sleep for the time specified. Useful on scripts
show holes Displays the database's holes
traverse Traverse a graph of records
truncate class Remove all the records of a class (by truncating all the underlying configured clusters)
truncate cluster Remove all the records of a cluster
truncate record Truncate a record you can't delete because it's corrupted
update Updates a record in the current database using the SQL syntax. To know more about the SQL syntax go here
help Prints this help
exit Closes the console

Extend the console with custom command

Edit the OConsoleDatabaseApp class and add a new method. There's an auto discovering system that put the new method between the available commands. To provide a description of the command use the annotations (look below). The command name must follow the Java code convention where to separate works just use the Camel-case.

So, for example, if you want to create the brand new "move cluster" command:

@ConsoleCommand(description = "Move the physical location of cluster files")
public void moveCluster(
  @ConsoleParameter(name = "cluster-name", description = "The name or the id of the cluster to remove") String iClusterName,
  @ConsoleParameter(name = "target-path", description = "path of the new position where to move the cluster files") String iNewPath ) {

  checkCurrentDatabase(); // THE DB MUST BE OPENED

  System.out.println("Moving cluster '" + iClusterName + "' to path " + iNewPath + "...");
}

If you type:

orientdb> help

Your new command will appear. And now try:

orientdb> move cluster foo /temp

Moving cluster 'foo' to path /temp...

Don't miss to contribute your command to the OrientDB Community! ;-)