Skip to content
toshihisa kajiwara edited this page Aug 25, 2014 · 23 revisions

OrientDB コンソールは OrientDB databases と Server instancesに対して機能するように作成されたJavaアプリケーションです。

インタラクティブモード (Interactive mode)

デフォルトのモードはインタラクティブモードです. bin/console.sh (Windows では bin/console.bat )スクリプトを実行してコンソールを立ち上げます. スクリプトの実行権限は正しく設定してあることを確認してください.

コンソールを起動してしまえば、コマンドの入力は可能です.

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

orientdb>

サポートされている全てのコマンドを確認するには commandsを確認してください.

バッチモード (Batch mode)

バッチモードでコマンドを実行するためには、 bin/console.sh (Windows では bin/console.bat ) スクリプトを全て";" セミコロンで区切り実行します. 例:

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

もう一つの方法は、実行したいコマンドの一覧を含むテキストファイル名を指定して実行する方法です. コマンドはセミコロン ";" で区切られている必要があります. 例:

orientdb> console.bat commands.txt

バッチモードで"ignoreErrors" に 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)

Orient consoleでサポートされている全てのコマンドを確認するには help もしくは ? を入力してください.

Command 説明
[[alter class sql alter class]]
[[alter cluster sql alter cluster]]
[[alter database sql alter database]]
[[alter property sql alter property]]
[[begin Console-Command-Begin]]
[[browse class Console-Command-Browse-Class]]
[[browse cluster Console-Command-Browse-Cluster]]
check database Checks the database integrity
classes 設定された全てのクラスを表示
[cluster status](Console Command Cluster Status) Displays the status of distributed cluster of servers
clusters 設定された全てのクラスタを表示
[[commit Console-Command-Commit]]
[[Console Command Compare Databases compare database]]
[[config Console-Command-Config]]
[[config get Console-Command-Config-Get]]
[[config set Console-Command-Config-Set]]
[[connect Console-Command-Connect]]
[[create class SQL Create Class]]
[[create cluster Console-Command-Create-Cluster]]
[[create cluster Console-Command-Create-Cluster]]
[[create database Console-Command-Create-Db]]
[[Console Command Create Data Segment create datasegment]]
[[create edge SQL-Create-Edge]]
[[create index SQL-Create-Index]]
[[create link SQL-Create-Link]]
[[create vertex SQL-Create-Vertex]]
[[declare intent Console-Command-Declare-Intent]]
[[delete Console-Command-Delete]]
[[dictionary keys Console-Command-Dictionary-Keys]]
[[dictionary get Console-Command-Dictionary-Get]]
[[dictionary put Console-Command-Dictionary-Put]]
[[dictionary remove Console-Command-Dictionary-Remove]]
[[disconnect Console-Command-Disconnect]]
[[display record Console-Command-Display-Record]]
[[Console Command Display Raw Record display raw record]]
[[drop class SQL-Drop-Class]]
drop cluster クラスタを削除
[[drop database Console-Command-Drop-Db]]
[[drop index SQL-Drop-Index]]
[[drop property SQL-Drop-Property]]
[[explain SQL-Explain]]
[[export database Console-Command-Export]]
[[export record Console-Command-Export-Record]]
[[find references SQL-Find-References]]
[[freeze database Console Freeze Database]]
[[get Console-Command-Get]]
[[grant SQL-Grant]]
[[import database Console-Command-Import]]
[[indexes Console Command Indexes]]
[[info Console-Command-Info]]
[[info class Console-Command-Info-Class]]
[[insert Console-Command-Insert]]
[[js Javascript-Command#via_console]]
[[jss Javascript-Command#via_console]]
[[list databases Console Command List Databases]]
[[load record Console-Command-Load-Record]]
[[Profiler Console-Command-Profiler]]
[[properties Console-Command-Properties]]
pwd Display current path
[[rebuild index SQL-Rebuild-Index]]
[[Console Release Database release database]]
[[reload record Console-Command-Reload-Record]]
[[Console Command Reload Schema reload schema]]
[[rollback Console-Command-Rollback]]
[[select Console-Command-Select]]
[[revoke SQL-Revoke]]
[[set Console-Command-Set]]
[[sleep Console Command Sleep]]
[[show holes Console-Command-Show-Holes]]
[[traverse SQL-Traverse]]
[[truncate class SQL Truncate Class]]
[[truncate cluster SQL Truncate Cluster]]
[[truncate record SQL Truncate Record]]
[[update Console-Command-Update]]
help ヘルプを表示
exit コンソールを閉じる

カスタムコマンドによるコンソールの拡張

OConsoleDatabaseApp class を編集して新しいメソッドを追加してください.追加した新しいメソッドはコマンドとして自動で認識されます。追加したコマンドの説明を提供する場合はアノテーションを使用してください. コマンドの名称はキャメルケースを使用するJavaのコーディング規約にしたがってください.

それでは例として、"move cluster"コマンドを新たに追加します:

@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 + "...");
}

下記のコマンドを入力してみましょう:

orientdb> help

あなたの新しいコマンドが表示されるはずです. 次に以下を試します:

orientdb> move cluster foo /temp
    
Moving cluster 'foo' to path /temp...

あなたのコマンドをOrientDB Community へ寄贈するのを忘れないで下さいね!;-)

Clone this wiki locally