当前位置:网站首页>Orientdb batch execute SQL
Orientdb batch execute SQL
2022-06-22 07:51:00 【Melody Limi】
Preface :
About orientDB There are still too few Chinese resources , It took several twists and turns to find out how to execute in batches orientDB SQL Script , The following is my batch execution SQL The way to , It can be used as a reference for beginners .
Come to the point :
We are at the beginning of learning orientDB when , Often only know in web Page run script , Only suitable for the development phase :

If you enter the testing or production stage , Need to update or initialize script , Such an interface only supports execution one by one , Not competent for every update script , And it is not suitable to judge the version execution .
So we need to look for the multiline command pattern :
[email protected]:~$ /opt/orientdb/bin/console.sh
OrientDB console v.3.2.2 (build 6df1d1942b88896dabea123fe1b8b0c6975e025a, branch develop) https://www.orientdb.com
Type 'help' to display all the supported commands.
orientdb> connect remote:localhost/demodb root root
Connecting to database [remote:localhost/demodb] with user 'root'...OK
orientdb {db=demodb}> script sql
[Started multi-line command. Type just 'end' to finish and execute]
The order is as follows :
1.linux open console.sh,Windows open console.bat
[email protected]:~$ /opt/orientdb/bin/console.sh2. Connect to database
demodb It's the database name ,root root Is the account password
orientdb> connect remote:localhost/demodb root root3. Enter multiline command mode ( With end Key words end )
orientdb {db=demodb}> script sqlBasic usage in multiline mode :
1. Modifying the table structure cannot use begin
--begin The transaction is started , Statements that modify the table structure cannot be used
script sql
create class Version extends V;
end2. The job change table data can be begin--commit perhaps begin--rollback
begin;
Create vertex Version set VersionNo='2021-12-31 18:00:00';
commit;
end3.if usage , Be careful (select result )
Error example :
script sql
begin;
let VersionNo = SELECT VersionNo FROM Version;
if($VersionNo = '2021-12-31 18:00:00') {
update Version set VersionNo='2022-02-12 17:56:00';
}
commit;
endThe results have not changed (VersionNo still 2021-12-31 18:00:00)
orientdb {db=demodb}> script sql
[Started multi-line command. Type just 'end' to finish and execute]
orientdb {db=demodb}> begin;
orientdb {db=demodb}> let VersionNo = SELECT VersionNo FROM Version;
orientdb {db=demodb}> if($VersionNo = '2021-12-31 18:00:00') {
orientdb {db=demodb}> update Version set VersionNo='2022-02-12 17:56:00';
orientdb {db=demodb}> }
orientdb {db=demodb}> commit;
orientdb {db=demodb}> end
+----+---------+
|# |operation|
+----+---------+
|0 |commit |
+----+---------+
Server side script executed in 0.003000 sec(s). Returned 1 records
orientdb {db=demodb}> select from Version
+----+------+-------+-------------------+
|# |@RID |@CLASS |VersionNo |
+----+------+-------+-------------------+
|0 |#445:0|Version|2021-12-31 18:00:00|
+----+------+-------+-------------------+
1 item(s) found. Query executed in 0.001 sec(s).Write it correctly ( The value should be $VersionNo[0]):
--select The result is an array , You need to take the first value to judge
script sql
begin;
let VersionNo = SELECT VersionNo FROM Version;
if($VersionNo[0] = '2021-12-31 18:00:00') {
update Version set VersionNo='2022-02-12 17:56:00';
}
commit;
endCorrect result (VersionNo Has been changed to 2022-02-12 17:56:00):
orientdb {db=demodb}> script sql
[Started multi-line command. Type just 'end' to finish and execute]
orientdb {db=demodb}> begin;
orientdb {db=demodb}> let VersionNo = SELECT VersionNo FROM Version;
orientdb {db=demodb}> if($VersionNo[0] = '2021-12-31 18:00:00') {
orientdb {db=demodb}> update Version set VersionNo='2022-02-12 17:56:00';
orientdb {db=demodb}> }
orientdb {db=demodb}> commit;
orientdb {db=demodb}> end
+----+---------+
|# |operation|
+----+---------+
|0 |commit |
+----+---------+
Server side script executed in 0.008000 sec(s). Returned 1 records
orientdb {db=demodb}> select from Version
+----+------+-------+-------------------+
|# |@RID |@CLASS |VersionNo |
+----+------+-------+-------------------+
|0 |#445:0|Version|2022-02-12 17:56:00|
+----+------+-------+-------------------+
1 item(s) found. Query executed in 0.001 sec(s).
orientdb {db=demodb}>边栏推荐
- A glimpse of easy rule
- Do you want to modify the title of the website
- Runloop detail summary
- Wechat games (3)
- mapTalks:基础操作与WMS/WMTS地图服务加载
- JS array flattening (recursive writing)
- JS to assign values to two objects with the same attributes
- Baidu Post Bar crawler crawls to the middle of the building
- 数据可视化优秀案例
- Wechat games (4)
猜你喜欢

模电实验——实验二 JFET共源极放大电路

Excellent cases of data visualization

Wx applet vant UI call interface to realize two-level cascade

Win openfeign from simple to deep

Phpcms mobile portal configuration
![[普通物理]波的能量与干涉](/img/fe/066aa9e8ed776b8f069b59b7123367.png)
[普通物理]波的能量与干涉

A training summary of Intranet penetration test

AutoCAD 2020.3 Chinese Version (old version)

Expérience électrique en mode - - expérience 2 circuit d'amplification de source commune JFET

Relative positioning, absolute positioning, fixed positioning
随机推荐
7、 Picker component
Open version - order delivery
【宋红康 MySQL数据库 】【高级篇】【06】MySQL的逻辑架构
Wechat games (2)
easy-rule 初窥
Open version - user level
AutoCAD 2020.3 Chinese Version (old version)
Runloop detail summary
A training summary of Intranet penetration test
XMIND 2022 mind map active resources?
[普通物理]波的能量与干涉
How to batch copy babies by sales volume in Taoying
简单是最好的网络推广的方法
phpcms手机门户网站配置
Remote Desktop Manager
Template code overview
Error e: unable to locate package sudo
【图论常见模板题】4种最短路解法和2种最小生成树解法
Backup the method of uploading babies in Taobao stores to multiple stores
模电实验——实验一 晶体管共射极单管放大器