Adds a value to a set. If the value is a collection, then it is merged with the set, otherwise is added.
Syntax − set()
2
map():
Adds a value to a map the first time the map is created. If is a map, then it is merged with the map, otherwise the pair and is added to map as new entry.
Syntax − map(, )
3
ist():
Adds a value to list the first time the list is created. If is a collection, then it is merged with the list, otherwise is added to list.
Syntax − list()
4
difference():
Works as aggregate or inline. If only one argument is passed then aggregates, otherwise executes, and returns the DIFFERENCE between the collections received as parameters.
Syntax − difference( [,]*)
5
first():
Retrieves only the first item of multi-value fields (arrays, collections and maps). For non-multi-value types just returns the value.
Syntax − first()
6
intersect():
Works as aggregate or inline. If only one argument is passed then aggregates, otherwise executes, and returns, the INTERACTION of the collections received as parameters.
Syntax − intersect( [,]*)
7
distinct():
Retrieves only unique data entries depending on the field you have specified as argument. The main difference compared to standard SQL DISTINCT is that with OrientDB, a function with parenthesis and only one field can be specified.
Syntax − distinct()
8
expand():
This function has two meanings−
When used on a collection field, it unwinds the collection in the field and uses it as result.
When used on a link (RID) field, it expands the document pointed by that link.
Syntax − expand()
9
unionall():
Works as aggregate or inline. If only one argument is passed then aggregates, otherwise executes and returns a UNION of all the collections received as parameters. Also works with no collection values.
Syntax − unionall( [,]*)
10
flatten():
Extracts the collection in the field and uses it as result. It is deprecated, use expand() instead.
Syntax − flatten()
11
last():
Retrieves only the last item of multi-value fields (arrays, collections and maps). For non-multi-value types just returns the value.
Syntax − last()
12
symmetricDifference():
Works as aggregate or inline. If only one argument is passed then aggregates, otherwise executes, and returns, the SYMMETRIC DIFFERENCE between the collections received as parameters.
Syntax − symmetricDifference( [,]*)
使用以下查询尝试一些收集功能。
执行以下查询以获取一组教师,即第9堂课。
orientdb {db = demo}>SELECT ID, set(teacher.id) AS teacherID from classess where class_id = 9
Returns a date formatting a string. is the date in string format, and is the date format following these rules.
Syntax − date( [] [,] )
2
sysdate():
Returns the current date and time.
Syntax − sysdate( [] [,] )
3
format():
Formats a value using the String.format() conventions.
Syntax − format( [, ](,]*.md)
4
distance():
Returns the distance between two points in the globe using the Haversine algorithm. Coordinates must be degrees.
Syntax − distance( , , , )
5
ifnull():
Returns the passed field/value (or optional parameter return_value_if_not_null). If field/value is not null, it returns return_value_if_null.
Syntax − ifnull(, [,](,]*)
6
coalesce():
Returns the first field/value not null parameter. If no field/value is not null, returns null.
Syntax − coalesce( [, ]*)
7
uuid():
Generates a UUID as a 128-bits value using the Leach-Salz variant.
Syntax − uuid()
8
if():
Evaluates a condition (first parameters) and returns the second parameter if the condition is true, the third one otherwise.
Syntax − if(, , )
使用以下查询尝试一些其他功能。
执行以下查询以了解如何执行if表达式。
orientdb {db = demo}> SELECT if(eval("name = 'satish'"), "My name is satish",
"My name is not satish") FROM Employee
如果上面的查询成功执行,您将获得以下输出。
----+--------+-----------------------
# |@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
----+--------+------------------------
执行以下查询以获取系统日期。
orientdb {db = demo}> SELECT SYSDATE() FROM Employee