如何执行定向数据库批处理脚本



我是第一次玩东方数据库。我已经启动并运行了它,我可以通过控制台执行简单的脚本。

但是,我真正想做的是使用额外的SQL Batch命令,例如"let"。

例如,来自维基的示例脚本:

begin
let account = create vertex Account set name = 'Luke'
let city = select from City where name = 'London'
let edge = create edge Lives from $account to $city
commit retry 100
return $edge

如果我使用这些命令编写脚本,控制台会抛出错误,因为它们似乎不受支持。维基建议这是因为它们只能通过Java和HTTP API获得。

将脚本内容粘贴到 Studio 中可以正常工作,但这是运行简单脚本的一种相当不令人满意的方式。

我是否缺少某些内容,或者是否无法通过简单的命令行指令运行包含 SQL Batch 命令的脚本?

您可以使用

script sql 命令从控制台执行它。请记住通过在新行上键入 end 来关闭它。例:

MacBook-Pro:bin luca$ ./console.sh
OrientDB console v.2.0-SNAPSHOT (build 2539) www.orientechnologies.com
Type 'help' to display all the supported commands.
Installing extensions for GREMLIN language v.2.6.0
orientdb> connect plocal:/temp/databases/ETLDemo admin admin
Connecting to database [plocal:/temp/databases/ETLDemo] with user 'admin'...OK
orientdb {db=ETLDemo}> script sql
[Started multi-line command. Type just 'end' to finish and execute]
orientdb {db=ETLDemo}> begin
orientdb {db=ETLDemo}> let a = create vertex v
orientdb {db=ETLDemo}> commit retry 100
orientdb {db=ETLDemo}> end
Server side script executed in 0,117000 sec(s). Value returned is: V#9:199 v1
orientdb {db=ETLDemo}>

最新更新