neo4j-cypher语言使用

neo4j-cypher语言使用

  1. neo4j的本质就是节点+关系。
  2. 节点是用小括号来表示,(节点:节点标签 {属性名称:属性值})
  3. with 本质是with(变量) 传送到下一个语句,with 子处理(变量), with 查询return 变量。
  4. unwind 本质就是for 循环。unwind(列表) as x 就是 for x in 列表
WITH [1, 2,4] AS a,[3, 4] AS b
with  a + b as c
unwind c as x 
return x order by x desc 
'''
4
4
3
2
1
'''
数据库相关操作

注意neo4j免费版不能创建数据库

create database test
show databases
use test
# create创建节点(node_name只是一个指代)
create (node_name:node_label{key1:value1, key2:value2,...})
create (n:boss{name:'biden', addr:'huashengdun'}) 
# create(创建有方向关系)
create (node_name:node_label)-[r:relation_name]->(node_name:node_label)
create (p1:boss)-[r:employ]->(p2:coder)
# merge (创建无方向关系)
create (p1:boss)-[r:marry]-[p1:boss_laopo]
# match
match(n:boss) where n.addr='huashengdun' return n.name, n, n.addr
match (n) return n (所有)

# merge, 增强查 查不到就创建,
merge (n:boss)
# delete
match(n:boss) delete n
# set
match (n:boss) where name='biden' set n.name='aobama'
# order by
match(n:boss) order by n.id
聚合
# count(), max/min/avg/sum
创建索引
# 给节点的属性创建索引
create index if not exists for (n:Lablename) on (n.proper1, n.proper2, n.proper3)
                                                 
# 给关系的属性创建索引
create index if not exists for ()-[r:Labelname]-() on (r.proper1, r.proper2)

相关推荐

  1. neo4j-cypher语言使用

    2024-01-11 11:06:03       56 阅读
  2. neo4j查询语言Cypher详解(五)--apoc

    2024-01-11 11:06:03       60 阅读
  3. Neo4j图形数据库查询,Cypher语言详解

    2024-01-11 11:06:03       29 阅读
  4. neo4jCypher语法记录

    2024-01-11 11:06:03       35 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-11 11:06:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-11 11:06:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-11 11:06:03       82 阅读
  4. Python语言-面向对象

    2024-01-11 11:06:03       91 阅读

热门阅读

  1. 深度解读:返利机器人自动赚佣金是怎么回事?

    2024-01-11 11:06:03       62 阅读
  2. 前端系列:ES6-ES12新语法

    2024-01-11 11:06:03       43 阅读
  3. 03 Strategy策略

    2024-01-11 11:06:03       46 阅读
  4. 关于Redis的事务

    2024-01-11 11:06:03       53 阅读