查询结点
1、查询表所有节点
match (n:table_node) return count(n);
2、查询去重后节点
match (n:table_node) return count(distinct n.table_name);
3、查看重复的id节点
match (n:table_node), (m:table_node) where n.table_name = m.table_name and id(n) <> id(m) return n,id(n);
查询下级节点
1、查询当前-下级节点
match (a)-->(b) where a.name = 'nodeName' return a,b
2、查询当前节点往下多少级的节点
# 备注:r*..3 是要显示的级数
match (a)-[r*..3]->(b) where a.name = 'nodeName' return a,b
查询节点的入度与出度
备注:可以用来分析节点被引用的频次等应用分析场景,辅助模型或架构升级重构文章来源地址https://www.toymoban.com/news/detail-521180.html
1、查询某个节点的入度与出度
MATCH (n:TableNode {name:"name"})
WITH count{(n)-[]->()} as out,
count{(n)<-[]-()} as in,
n
RETURN n,out,in
2、查询所有节点入度与出度
match (n:TableNode)
with n,
count{(n)-[]->()} as out,
count{(n)<-[]-()} as in
return n.name, out,in
order by n.name desc ;
3、查询入度与出度 为0 的节点
match (n:TableNode)
with n,
count{(n)-[]->()} as out,
count{(n)<-[]-()} as in
where in = 0 and out = 0
return n.name, out,in
order by n.name desc ;
删除结点
1、删除所有结点
match (n:table_node) delete n;
2、删除重复节点中的其中一个
MATCH (b:TableNode)
WITH b.name AS name, COLLECT(b) AS branches
WHERE SIZE(branches) > 1
FOREACH (n IN TAIL(branches) | DETACH DELETE n);
文章来源:https://www.toymoban.com/news/detail-521180.html
到了这里,关于neo4j - 常用sql的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!