📜  Neo4j CQL-简介

📅  最后修改于: 2020-11-27 06:49:28             🧑  作者: Mango


CQL代表Cypher Query Language。就像Oracle数据库具有查询语言SQL一样,Neo4j也具有CQL作为查询语言。

Neo4j CQL

  • 是Neo4j图形数据库的查询语言。
  • 是一种声明式模式匹配语言。
  • 遵循类似SQL的语法。
  • 语法非常简单,并且易于阅读。

像Oracle SQL

  • Neo4j CQL具有执行数据库操作的命令。

  • Neo4j CQL支持许多子句,例如WHERE,ORDER BY等,以轻松的方式编写非常复杂的查询。

  • Neo4j CQL支持某些功能,例如字符串,聚合。除了它们,它还支持一些关系函数。

Neo4j CQL子句

以下是Neo4j的Çypher Q uery大号anguage的阅读条款-

Sr.No Read Clauses Usage
1 MATCH This clause is used to search the data with a specified pattern.
2 OPTIONAL MATCH This is the same as match, the only difference being it can use nulls in case of missing parts of the pattern.
3 WHERE This clause id is used to add contents to the CQL queries.
4 START This clause is used to find the starting points through the legacy indexes.
5 LOAD CSV This clause is used to import data from CSV files.

以下是Neo4j的Çypher Q uery大号anguage的写入条款-

Sr.No Write Clause Usage
1 CREATE This clause is used to create nodes, relationships, and properties.
2 MERGE This clause verifies whether the specified pattern exists in the graph. If not, it creates the pattern.
3 SET This clause is used to update labels on nodes, properties on nodes and relationships.
4 DELETE This clause is used to delete nodes and relationships or paths etc. from the graph.
5 REMOVE This clause is used to remove properties and elements from nodes and relationships.
6 FOREACH This class is used to update the data within a list.
7 CREATE UNIQUE Using the clauses CREATE and MATCH, you can get a unique pattern by matching the existing pattern and creating the missing one.
8 Importing CSV files with Cypher Using Load CSV you can import data from .csv files.

以下是Neo4j的Çypher Q uery大号anguage的一般条款-

Sr.No General Clauses Usage
1 RETURN This clause is used to define what to include in the query result set.
2 ORDER BY This clause is used to arrange the output of a query in order. It is used along with the clauses RETURN or WITH.
3 LIMIT This clause is used to limit the rows in the result to a specific value.
4 SKIP This clause is used to define from which row to start including the rows in the output.
5 WITH This clause is used to chain the query parts together.
6 UNWIND This clause is used to expand a list into a sequence of rows.
7 UNION This clause is used to combine the result of multiple queries.
8 CALL This clause is used to invoke a procedure deployed in the database.

Neo4j CQL功能

以下是常用的Neo4j CQL函数-

Sr.No CQL Functions Usage
1 String They are used to work with String literals.
2 Aggregation They are used to perform some aggregation operations on CQL Query results.
3 Relationship They are used to get details of relationships such as startnode, endnode, etc.

我们将在后续章节中详细讨论所有Neo4j CQL命令,子句和函数的语法,用法和示例。

Neo4j CQL数据类型

这些数据类型类似于Java语言。它们用于定义节点或关系的属性。

Neo4j CQL支持以下数据类型-

Sr.No CQL Data Type Usage
1 Boolean It is used to represent Boolean literals: true, false.
2 byte It is used to represent 8-bit integers.
3 short It is used to represent 16-bit integers.
4 int It is used to represent 32-bit integers.
5 long It is used to represent 64-bit integers.
6 float It is used to represent 32-bit floating-point numbers.
7 double It is used to represent 64-bit floating-point numbers.
8 char It is used to represent 16-bit characters.
9 String It is used to represent Strings.

CQL运算符

以下是Neo4j Cypher Query语言支持的运算符列表。

Sr.No Type Operators
1 Mathematical +, -, *, /, %, ^
2 Comparison +, <>, <, >, <=, >=
3 Boolean AND, OR, XOR, NOT
4 String +
5 List +, IN, [X], [X…..Y]
6 Regular Expression =-
7 String matching STARTS WITH, ENDS WITH, CONSTRAINTS

Neo4j CQL中的布尔运算符

Neo4j支持以下布尔运算符,以在Neo4j CQL WHERE子句中使用以支持多个条件。

Sr.No Boolean Operators Description
1 AND It is a Neo4j CQL keyword to support AND operation. It is like SQL AND operator.
2 OR It is a Neo4j CQL keyword to support OR operation. It is like SQL AND operator.
3 NOT It is a Neo4j CQL keyword to support NOT operation. It is like SQL AND operator.
4 XOR It is a Neo4j CQL keyword to support XOR operation. It is like SQL AND operator.

Neo4j CQL中的比较运算符

的Neo4j支持以下运算符中的Neo4j CQL使用WHERE子句来支持的条件。

Sr.No Boolean Operators Description
1 = It is a Neo4j CQL “Equal To” operator.
2 < > It is a Neo4j CQL “Not Equal To” operator.
3 < It is a Neo4j CQL “Less Than” operator.
4 > It is a Neo4j CQL “Greater Than” operator.
5 <= It is a Neo4j CQL “Less Than Or Equal To” operator.
6 > = It is a Neo4j CQL “Greater Than Or Equal To” operator.