创建一个节点,不管是否重复 | create (a:person{name:'张三三',sex:'男性',telphone:'15038067939'}) |
Merge,有则不动没则新加 | merge (a:person{name:'张三三',sex:'男性',telphone:'15038067939'}) |
按属性查询节点 | match (a:person) where a.name='张三三' return a |
按关系名称查询节点 | match p=()-[r:`夫妻`]->() return p |
查询全部节点 | match (a) return a |
强制清空全部数据 | match (n) detach delete n |
删除指定数据 | match (a:person) where a.name='张三三' delete a |
创建两个节点,带上关系 | create (n:person{name:'张1'}) -[r:R{type:'朋友'}]->(b:person{name:'张2'}) return n,b |
创建两个节点,带上关系 | create (n:person{name:'张1'}) -[r:夫妻]->(b:person{name:'张2'}) return n,b |
修改节点属性 | match (a:person) where a.name='张1' set a.sex='女',a.telphone='13154411221' return a |
删除节点指定属性 | match(n:person) where n.name='张1' remove n.sex return n |
查询所有带关系的节点 | match p=()-->() return p |
删除所有带关系的节点 | match p=()-->() delete p |
删除指定关系的节点 | match p=()-[r:`夫妻`]->() delete p |
删除指定关系 | MATCH (a:person) -[r:夫妻]-(b:person) delete r |
为两个节点添加关系 | match (a:person{name:'张三丰'}) , (b:person{name:'风清扬'}) create (a) -[r:对手] -> (b) |
综合练习,逐条语句 | merge (a:person{name:'张三丰',sex:'男性',telphone:'15038067939'}) merge (b:person{name:'风清扬',sex:'男性',telphone:'45038067939'}) merge (c:person{name:'李四四',sex:'男性',telphone:'35038067939'}) merge (d:person{name:'灭绝',sex:'女性',telphone:'12038067939'}) create (a:person{name:'张三丰'}) -[r:对手] -> (b:person{name:'风清扬'}) match (a:person{name:'张三丰'}) , (b:person{name:'风清扬'}) create (a) -[r:对手] -> (b) match (a:person{name:'张三丰'}) , (b:person{name:'灭绝'}) create (a) -[r:情人] -> (b) match (a:person{name:'风清扬'}) , (b:person{name:'李四四'}) create (a) -[r:师徒] -> (b) match (a:person{name:'灭绝'}) , (b:person{name:'李四四'}) create (a) -[r:母子] -> (b) match (a:person{name:'张三丰'}) , (b:person{name:'李四四'}) create (a) -[r:私生子] -> (b) |
修改关系(关系没法修改,需要删除重新创建) | 查询指定数据,重定义关系 match (a:person{name:'张三丰'})-[old:私生子]->(b:person{name:'李四四'}) create (a)-[new:父子]->(b) delete old 查询包含指定关系的数据,重定义关系 match (a:person) -[old:父子] -> (b:person) create (a)-[new:私生子]->(b) delete old |
dump备份 | 在bin目录执行 neo4j-admin.bat dump --database=tdzz --to=E:/dd.dump |
dump备份文件还原 | 在bin目录执行 neo4j-admin.bat load --from=tdzz.dump --database=tdzz --force |
Neo4j 切换数据库 | 按下图修改之后,重启
|
neo4j 常用功能和语句整理
最新推荐文章于 2023-03-16 13:39:39 发布