OrientDB功能

2018-12-24 09:41 更新

本章介紹了OrientDB中不同類型功能的完整參考。 下表定義了按功能分類的功能列表。
圖形函數(shù)
用于操作圖形數(shù)據(jù)的函數(shù)。
嘗試一些圖形函數(shù)以及以下查詢。
執(zhí)行以下查詢以從所有車輛頂點(diǎn)獲取所有出站頂點(diǎn)。

orientdb {db = demo}>SELECT out() from Vehicle

如果上面的查詢執(zhí)行成功,你會(huì)得到下面的輸出。

---+----------+--------- 
 # | @class   | out 
---+----------+--------- 
 0 | Vehicle  | #11:2 
 1 | Vehicle  | #13:1 
 2 | Vehicle  | #13:4 
---+----------+--------- 

執(zhí)行以下查詢以從頂點(diǎn)#11:3獲取傳入和傳出頂點(diǎn)。

orientdb {db = demo}>SELECT both() FROM #11:3 

如果上面的查詢執(zhí)行成功,你會(huì)得到下面的輸出。

---+----------+--------+------- 
 # | @class   | out    | in  
---+----------+--------+------- 
 0 | Vehicle  | #13:2  | #10:2   
 ---+----------+-------+-------

數(shù)學(xué)函數(shù)

下表定義了用于執(zhí)行數(shù)學(xué)表達(dá)式的Math函數(shù)列表。
使用以下查詢嘗試一些數(shù)學(xué)函數(shù)。
執(zhí)行以下查詢以獲取所有員工的工資總和。

orientdb {db = demo}>SELECT SUM(salary) FROM Employee 

如果上面的查詢執(zhí)行成功,你會(huì)得到下面的輸出。

---+----------+--------- 
 # | @CLASS   | sum 
---+----------+--------- 
 0 | null     | 150000 
---+----------+---------

執(zhí)行以下查詢來(lái)獲取所有員工的平均工資。

orientdb {db = demo}>SELECT avg(salary) FROM Employee

如果上面的查詢執(zhí)行成功,你會(huì)得到下面的輸出。

---+----------+--------- 
 # | @CLASS   | avg 
---+----------+--------- 
 0 | null     | 25 
---+----------+--------- 

集合函數(shù)

下表定義操作集合數(shù)據(jù)的函數(shù)列表。
使用以下查詢嘗試一些收集函數(shù)。
執(zhí)行以下查詢以獲取9班的教師資料。

orientdb {db = demo}>SELECT ID, set(teacher.id) AS teacherID from classess where class_id = 9 

如果上面的查詢執(zhí)行成功,你會(huì)得到下面的輸出。

---+----------+--------+-------------------------- 
 # | @CLASS   | id     | TeacherID 
---+----------+--------+-------------------------- 
 0 | null     | 9     |   1201, 1202, 1205, 1208 
---+----------+-------+---------------------------

其他功能

下表定義了執(zhí)行雜項(xiàng)操作的函數(shù)列表。
使用以下查詢嘗試一些Misc函數(shù)。
執(zhí)行以下查詢以了解如何執(zhí)行if表達(dá)式。

orientdb {db = demo}> SELECT if(eval("name = 'satish'"), "My name is satish", 
"My name is not satish") FROM Employee

如果上面的查詢執(zhí)行成功,你會(huì)得到下面的輸出。

----+--------+----------------------- 
#   |@CLASS  | IF 
----+--------+----------------------- 
0   |null    |My name is satish  
1   |null    |My name is not satish 
2   |null    |My name is not satish  
3   |null    |My name is not satish  
4   |null    |My name is not satish  
----+--------+------------------------ 

執(zhí)行以下查詢來(lái)獲取系統(tǒng)日期。

orientdb {db = demo}> SELECT SYSDATE() FROM Employee

如果上面的查詢執(zhí)行成功,你會(huì)得到下面的輸出。

----+--------+----------------------- 
#   |@CLASS  | SYSDATE 
----+--------+----------------------- 
0   |null    |2016-02-10 12:05:06 
1   |null    |2016-02-10 12:05:06 
2   |null    |2016-02-10 12:05:06 
3   |null    |2016-02-10 12:05:06 
4   |null    |2016-02-10 12:05:06 
----+--------+------------------------ 

利用此功能完全可以很容易地操縱OrientDB數(shù)據(jù)。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)