Neo4j 入门教程

参考网站:https://www.w3cschool.cn/neo4j/

mysql数据导入neo4j数据库
// 使用Apoc.jar包将mysql数据导入neo4j数据库
CALL apoc.load.jdbc('jdbc:mysql://192.168.41.140/test2?user=root&password=123456&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC','select * from test2') YIELD row CREATE (n:User{id:row.id,name2:row.name2})
create创建节点
create (p:People{id:1,name:"a"})
create (p:People:Student)
创建关系(根据现有节点)
match (p:People),(c:Company) where p.id=1 and c.id=1 create (p) - [r:WorkAt{workDate:"2021"}] -> (c)
where条件查询
match(p:People) where p.id=1 return p
match(p:People{id:1}) return p
delete删除节点或关系。
match(p:People) where p.id=2 delete p
match (p:People) - [r] - (c:Company) delete p,c,r
remove删除节点的属性、节点的标签、关系的属性。
match (p:People) remove p.id
match (p:People) remove p:People
set增加节点的属性或关系的属性
match (p:People) set p.name="aaa"
order by 排序
match (p:People) return p order by p.name
union数据组合(不包含重复行)
MATCH (cc:CreditCard)
RETURN cc.id as id,cc.number as number,cc.name as name,
   cc.valid_from as valid_from,cc.valid_to as valid_to
UNION
MATCH (dc:DebitCard)
RETURN dc.id as id,dc.number as number,dc.name as name,
   dc.valid_from as valid_from,dc.valid_to as valid_to
union all 它结合并返回两个结果集的所有行成一个单一的结果集(包含两个节点的重复行)
MATCH (cc:CreditCard)
RETURN cc.id as id,cc.number as number,cc.name as name,
   cc.valid_from as valid_from,cc.valid_to as valid_to
UNION ALL
MATCH (dc:DebitCard)
RETURN dc.id as id,dc.number as number,dc.name as name,
   dc.valid_from as valid_from,dc.valid_to as valid_to
limit 过滤或限制查询返回的行数
MATCH (emp:Employee) RETURN emp LIMIT 2

skip 查询结果集顶部的结果(跳过几行)
MATCH (emp:Employee) RETURN emp SKIP 2
merge

merge=create+match 不存在才新建

你可能感兴趣的:(Neo4j 入门教程)