Skip to content
Luca Garulli edited this page Mar 30, 2014 · 23 revisions

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.1.0 (build 11200) 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

Console commands

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

Command Description
Console Command Alter Class Changes the class schema
Console Command Alter Class Changes the cluster attributes
Console Command Alter Class Changes the database attributes
Console Command 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
Console Command Check Database Checks the database integrity
classes Displays all the configured classes
Console Command Cluster Status Displays the status of distributed cluster of servers
clusters Displays all the configured clusters
commit Commits an active transaction
Console Command Compare Databases Compare 2 databases
[compact database](SQLCompactDatabase) Compacts the database reducing the free holes
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
Console Command Copy Database Copies a database to a remote server
create cluster Creates a new cluster inside a database
create class Creates a new class
create cluster Creates a new record cluster
create database Creates a new database
Console Command Create Data Segment Creates a new data-segment
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
Console Command Display Raw Record Displays current record's raw format
drop class Drop a class
[drop cluster](SQLDropCluster) 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
Console Freeze Database Freezes the database locking all the changes. Use this to raw backup. Once frozen it use the Console 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
Console Command 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
Console Command 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
Console Release Database Releases a Console Freeze Database database
reload record Reloads a record in memory and set it as the current one
Console Command 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
Console Command Sleep Sleep for the time specified. Useful on scripts
show holes Displays the database's holes
traverse Traverse a graph of records
Console Command Truncate Class Remove all the records of a class (by truncating all the underlying configured clusters)
Console Command Truncate Cluster Remove all the records of a cluster
Console Command 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! ;-)

Clone this wiki locally