neo4j-cypher语言使用

neo4j-cypher语言使用

  1. neo4j的本质就是节点+关系。
  2. 节点是用小括号来表示,(节点:节点标签 {属性名称:属性值})
  3. with 本质是with(变量) 传送到下一个语句,with 子处理(变量), with 查询return 变量。
  4. unwind 本质就是for 循环。unwind(列表) as x 就是 for x in 列表
cypher 复制代码
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免费版不能创建数据库

cypher 复制代码
create database test
show databases
use test
cypher 复制代码
# 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]
cypher 复制代码
# match
match(n:boss) where n.addr='huashengdun' return n.name, n, n.addr
match (n) return n (所有)

# merge, 增强查 查不到就创建,
merge (n:boss)
cypher 复制代码
# delete
match(n:boss) delete n
cypher 复制代码
# set
match (n:boss) where name='biden' set n.name='aobama'
cypher 复制代码
# order by
match(n:boss) order by n.id
聚合
cypher 复制代码
# count(), max/min/avg/sum
创建索引
cypher 复制代码
# 给节点的属性创建索引
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)
相关推荐
QEasyCloud202210 分钟前
WooCommerce 独立站系统集成技术方案
java·前端·数据库
小鸡吃米…28 分钟前
TensorFlow 实现异或(XOR)运算
人工智能·python·tensorflow·neo4j
数据知道1 小时前
MongoDB 数组查询专项:`$all`、`$elemMatch` 与精确匹配数组的使用场景
数据库·mongodb
柒.梧.1 小时前
Java位运算详解:原理、用法及实战场景(面试重点)
开发语言·数据库·python
callJJ1 小时前
深入浅出 MVCC —— 从零理解 MySQL 并发控制
数据库·mysql·面试·并发·mvcc
小杜的生信筆記1 小时前
生信技能技巧小知识,Linux多线程压缩/解压工具
linux·数据库·redis
Smoothcloud润云2 小时前
Google DeepMind 学习系列笔记(3):Design And Train Neural Networks
数据库·人工智能·笔记·深度学习·学习·数据分析·googlecloud
银发控、2 小时前
MySQL覆盖索引与索引下推
数据库·mysql·面试
DolphinDB智臾科技2 小时前
DolphinDB 与英方软件达成兼容互认,共筑高效数据新底座
数据库·时序数据库·dolphindb
ZJun_Ocean2 小时前
add_columns
数据库·sql