语法CREATE 用来创建节点和关系
CREATE (n)
CREATE (n),(m)
返回全部节点
MATCH (p) RETURN p
我们发现这三个节点其实都是空节点,只有id不同,别的都一样
CREATE (n:Person)
创建个带多个标签的节点
CREATE (n:Person:China)
这是个人,这个人是中国的,一个节点拥有两个标签
CREATE (n:Person {name: 'Tomas Chen', title: 'Developer'})
创建了节点n,标签为Person,他有两个属性1.名字叫Tomas Chen 2.他的抬头是开发者
CREATE (a {name: 'Andy Wang'}) RETURN a.name
CREATE (p:Person{name:'Jim'})-[r:LIKES]->(p2:Person{name:'Lucy'})
MATCH p=()-[r:LIKES]->() RETURN p LIMIT 25
CREATE (:Person {name: 'A'})
CREATE (:Person {name: 'B'})
MATCH (a:Person), (b:Person)
WHERE a.name = 'A' AND b.name = 'B' CREATE (a)-[r:KNOWS]->(b)
RETURN type(r)
MATCH (a:Person), (b:Person)
WHERE a.name = 'A' AND b.name = 'B'
CREATE (a)-[r:LIKES {name: a.name + ' likes ' + b.name}]->(b)
RETURN type(r), r.name
╒═════════╤═══════════╕
│"type(r)"│"r.name" │
╞═════════╪═══════════╡
│"LIKES" │"A likes B"│
CREATE p = (:Person{name:'Wang Wu'})-[:WORKS_AT]->(:IBM{name:'IBM Company'})<-[:WORKS_AT]-(:Person{name: 'Li Lei'})
RETURN p