Neo4j database operation command
1. Create a node:
create(name:label) (node:label) No information node
create(dept:Dept{deptno:10,dname:“Accounting”,location:“Hyderbad”})
{fillable data type: content} has information nodes
create(Name:name1:name2:name3) # One node with three labels
1.1 Create node relationship:
CREATE (p1:Profile1)-[r1:LIKES]->(p2:Profile2) # Created two nodes and their relationship [relationship name: label]
match(n: 人
),(j: 料
) where n.name="corresponding name" and j.name create(n)-[r:test{mes:"test",age=100}]->(j)return r # Match to find the corresponding relationship to create a relationship between two nodes (new relationship)
1.2 Create Node Attribute Information Set Add
Add attribute information to the Set Book node
match(book:Book) set book.pages=“666” return book
2. Query node:
Query all nodes under this attribute
match (n:dept)return n
n # query under the dep node id=1 age=100 child node
match(n:dept{id:1,age:100}) return
Query the node with age=100 under the dep node
match(n:dept) where n.age=100 return n
Judgment condition where query
match(n: 机
) where n.name="node name" or n.name="node name" return n
The number of records returned by the query. limit times (query up)
MATCH (n:机
) RETURN n LIMIT 25
Skip returned results skip? indivual
MATCH (n:标签
) RETURN n skip 2
3. Delete node
delete a single node
match(n:标签
) delete n
Delete all data (delete database and run away)
match (n) detach delete n
Delete a node and its relationship
match(n:A
)-[r]-(j:B
) delete n,j,r
Delete node attribute Remove
match(book:Book) remove book.pages return book
Delete a node by an id attribute
MATCH ( r ) WHERE id (r ) = 492 DELETE r
Delete a node and all its relationships
MATCH ( r ) WHERE id (r ) = 493 DETACH DELETE r
4. Node sorting
Called descending order using the sorted result
match(n:机
) return n.id order by n.id desc
5. Merge
Restrictions: Result column types and names from both sets of results must match, which means column names should be the same and columns' data types should be the same.
It combines and returns common rows from two sets of results into one set of results. It does not return duplicate rows from two nodes.
match(n:料
) return n.name as name union match(j:机
) return j.name as name
Boolean Operators in Neo4j CQL
Neo4j supports the following Boolean operators to be used in Neo4j CQL WHERE clause to support multiple conditions.
S.No. Boolean operator description
1 AND and.
2 OR or.
3 NOT No.
4 XOR Exclusive OR.
Comparison Operators in Neo4j CQL
Neo4j supports the following comparison operators, which are used in Neo4j CQL WHERE clauses to support conditions.
S.No. Boolean Operator Description
- = It is the Neo4j CQL "equal to" operator.
- <> It is a Neo4j CQL "not equal to" operator.
- < It is a Neo4j CQL "less than" operator.
-
It is a Neo4j CQL "greater than" operator.
- <= It is a Neo4j CQL "less than or equal to" operator.
-
= It is a Neo4j CQL "greater than or equal to" operator.