OrientDB

OrientDB

简介

sql 操作

console cmd

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
$ connect remote:localhost/Demo root hello plocal

$ update edge organRelation
set relation_key='warehouse|139|3_basesite|691704_2019-01-10_2019-01-10_2019-01-10',
order_date='2019-01-10',
service_type_list=['1'],
operate_date='2019-01-10',
order_type_list=['1','2'],
aging_type_list=['2','1','10','3'],
handdown_date='2019-01-10',
ts=1547122222751,
in=(select from organ where organ_key='basesite|691704'),
out=(select from organ where organ_key='warehouse|139|3')
upsert
where relation_key='warehouse|139|3_basesite|691704_2019-01-10_2019-01-10_2019-01-10'


update edge teach
from (select from Teacher where fullname='field1' limit 10)
to (select from student where s_name='field1' limit 10)
set relation=1
upsert where relation=1

UPDATE EDGE teach
FROM (SELECT FROM Teacher where fullname = 'field1' )
TO ( SELECT FROM student WHERE s_name= 'field1' )
relation = 1
UPSERT
WHERE  relation = 1


UPDATE EDGE Friend SET out = (SELECT FROM Person WHERE name = 'John')
          WHERE foo = 'bar'

UPDATE EDGE hasAssignee
FROM ( SELECT FROM Project WHERE id=:id )
TO ( SELECT FROM User WHERE login in :login )
UPSERT
WHERE hasAssignee.id = 56


UPDATE EDGE teach
FROM ( SELECT FROM Teacher WHERE name = 'Jay2' limit 1 )
TO ( SELECT FROM Student WHERE name= 'Tom1' limit 1 )
UPSERT
WHERE class = "chinese"

CREATE PROPERTY User.name STRING
CREATE PROPERTY teach.relation INT
UPDATE EDGE teach  SET IN = (SELECT FROM Teacher where fullname = 'field1' ) OUT = ( SELECT FROM student WHERE s_name= 'field1' ) relation = 1 UPSERT WHERE relation = 1



1. insert vertex
CREATE CLASS Teacher EXTENDS V;
CREATE CLASS Student EXTENDS V;

CREATE VERTEX Teacher CONTENT { "name" : "Jay", "surname" : "Miner" };
CREATE VERTEX Student CONTENT { "name" : "Tom", "surname" : "Miner" };

INSERT INTO Teacher (name, surname) VALUES ("Jay1", "Miner1");
INSERT INTO Teacher (name, surname) VALUES ("Jay2", "Miner2");
INSERT INTO Teacher (name, surname) VALUES ("Jay3", "Miner3");

INSERT INTO Student (name, surname) VALUES ("Tom1", "Miner1");
INSERT INTO Student (name, surname) VALUES ("Tom2", "Miner2");
INSERT INTO Student (name, surname) VALUES ("Tom3", "Miner3");


2. update vertex
UPDATE Teacher SET name = 'Jay3' WHERE @rid = #
UPDATE Student SET name = 'Jay3' WHERE name == 'Jay'


3. insert edge
CREATE CLASS teach EXTENDS E;
CREATE EDGE teach FROM ( select from Teacher where name == "Jay1" limit 1) To ( select from Student where name == "Tom1" limit 1) Content {"class": "chinese"};


4. update edge

UPDATE EDGE teach FROM ( SELECT FROM Teacher WHERE name = 'Jay2' limit 1 ) TO ( SELECT FROM Student WHERE name= 'Tom1' limit 1 ) UPSERT WHERE class = "chinese"
UPDATE EDGE teach SET
in = ( SELECT FROM Teacher WHERE name = 'Jay2' limit 1 ),
out = ( SELECT FROM Student WHERE name= 'Tom1' limit 1 )
UPSERT
WHERE class == "chinese"


update teach set in = #73:105, out = #73:106 where @rid = #121:2

update teach
set in = (select rid from index:tid where key = ["#73:10000"] limit 1 ) ,
out = (select rid from index:tid where key = ["#73:12002"] limit 1)
upsert
where @rid = #121:10
limit 1


### 1. 定义Vertex
```sql
CREATE CLASS Person EXTENDS V;
CREATE PROPERTY Person.name STRING;
CREATE PROPERTY Person.age INTEGER;
CREATE PROPERTY Person.createTime DATETIME;

2. 建立索引

1
CREATE INDEX Person.name NOTUNIQUE

3. 插入 vertex 数据

1
2
3
4
INSERT INTO Person (name, age, createTime) VALUES ("Petter001", 26, "2019-01-26 10:22:11");
CREATE VERTEX Person CONTENT { "name": "Petter002", "age": 26, "createTime": "2019-01-26 10:22:11"};
CREATE VERTEX Person CONTENT { "name": "Petter003", "age": 26, "createTime": "2019-01-26 10:22:11"};
CREATE VERTEX Person CONTENT { "name": "Petter004", "age": 26, "createTime": "2019-01-26 10:22:11"};

4. 更新 vertex 数据

1
2
UPDATE (select rid INDEX:Person where key = ["Petter00"] limit 1) SET age = 15
SELECT FROM Person where name = "ptest_018"

5. 定义 Edge

1
2
3
CREATE CLASS call EXTENDS E;
CREATE PROPERTY call.name STRING;
CREATE PROPERTY call.createTime DATETIME;

6. 建立索引

1
2
CREATE INDEX call.name NOTUNIQUE;
CREATE INDEX packageByName ON Package (name) FULLTEXT ENGINE LUCENE

7. 插入 Edge 数据

1
2
CREATE EDGE call FROM (select from Person where name = "Petter001" limit 1) TO (select from Person where name = "Petter002" limit 1) SET name = "12132", createTime = "2019-01-26 10:22:11"
CREATE EDGE call FROM (select expand(rid) from index:Person.name where key = ["ptest_03190015"] limit 1) TO (select expand(rid) from index:Person.name where key = ["ptest_01190015"] limit 1) SET name = "ptest_InsertEdge", createTime = "2019-01-22 18:43:25"

8. 更新 Edge

1
2
UPDATE  (select expand(rid) from index:call.name where key = "12132" limit 1) SET out = (select expand(rid) from index:Person.name where key = ["ptest_03190015"] limit 1) , in = (select expand(rid) from index:Person.name where key = ["ptest_03190016"] limit 1)
SELECT FROM call where name = "ptest_0180825"
updatedupdated2024-08-252024-08-25