neo4j

neo4j_第1张图片

1.添加节点属性

MATCH (n { name: 'Andy' })
SET n.surname = 'Taylor'
RETURN n.name, n.surname

2.限定条件下添加节点属性

MATCH (n { name: 'Andy' })
SET (
CASE
WHEN n.age = 36
THEN n END ).worksIn = 'Malmo'
RETURN n.name, n.worksIn

3.更新属性

MATCH (n { name: 'Andy' })
SET n.age = toString(n.age)
RETURN n.name, n.age

4.设置为null

MATCH (n { name: 'Andy' })
SET n.name = NULL RETURN n.name, n.age

5.交换节点属性

MATCH (at { name: 'Andy' }),(pn { name: 'Peter' })
SET at = pn
RETURN at.name, at.age, at.hungry, pn.name, pn.age

6.同时设置多个属性

MATCH (p { name: 'Peter' })
SET p = { name: 'Peter Smith', position: 'Entrepreneur' }
RETURN p.name, p.age, p.position

7.同时设置为null

MATCH (p { name: 'Peter' })
SET p = { }
RETURN p.name, p.age

8.批量增加属性

MATCH (p { name: 'Peter' })
SET p += { age: 38, hungry: TRUE , position: 'Entrepreneur' }
RETURN p.name, p.age, p.hungry, p.position

9.set设置多个属性

MATCH (n { name: 'Andy' })
SET n.position = 'Developer', n.surname = 'Taylor'

10.通过参数设置属性

{
  "surname" : "Taylor"
}

MATCH (n { name: 'Andy' })
SET n.surname = $surname
RETURN n.name, n.surname

11.通过参数设置多个属性

{
  "props" : {
    "name" : "Andy",
    "position" : "Developer"
  }
}

MATCH (n { name: 'Andy' })
SET n = $props
RETURN n.name, n.position, n.age, n.hungry

12.设置标签

MATCH (n { name: 'Stefan' })
SET n:German
RETURN n.name, labels(n) AS labels

13.设置多个标签

MATCH (n { name: 'George' })
SET n:Swedish:Bossman
RETURN n.name, labels(n) AS labels

参考文献:
https://neo4j.com/docs/developer-manual/3.4/cypher/clauses/set/

你可能感兴趣的:(数据库)