Neo4j基础操作速查表

2020-05-22 00:00:00 删除 节点 是一个 属性 标签

1.创建节点

create (n) ;


view created node

match (n) return n;


2. 创建多个节点

create (n),(m) ;

match (n) return n;


3.通过id搜索节点

match (n) where id(n)=1 return n;

搜索时可以使用<. <= .. 这些关系操作

match (n) where id(n)<=6 return n;

match (n) where id(n) in [1,2,0] return n;


4.删除节点

match (n) where id(n) = 1 delete n;

match (n) return n;

delete multi node

match (n) where id(n) in [2,3] delete n;


删除所有节点

match (n) delete n;


更快的全库删除方法:

sudo service neo4j stop

sudo service neo4j start

sudo service neo4j status
sudo rm -rf /var/lib/neo4j/data/*


5.通过标签搜索节点

create (n:Person) ;

match (n) where n:Person return n;


create node with multi labels

create (n:Person:Indian)

match (n) where n:Person:Indian return n;

match (n) where n:Person or n:Indian return n;


6. 为已存在节点添加标签

match (n) set n:Employee return n;

match (n) where id(n)=0 set n:Manager return n;

match (n) where id(n) in [2,3] set n:TeamLeader;


7. 删除标签、更新标签

match (n) remove n:Person return n;

match (n) where id(n) in [2,3] remove n:Employee return n;

match (n) remove n:Vacation:Food return n;


match (n) where id(n) =0 remove n:Manager set n:Director return n;


8.查询标签

match (n) return distinct labels(n);

match (n) where id(n)=0 return labels(n);

match (n) return distinct count(labels(n));

match (n) return disinct count(lables(n)),labels(n);

match (n) where n:TeamLeader delete n;


9.创建有属性的节点

create (x:Book{title:"The White Tigger"}) return x;

create (x:Book{title:"The Three Mistakes of My Life",author:"Chetan Bhagat",publisher:"Rupa * Co."}) return x;

create (n:Book{title:"红楼梦",author:"曹雪芹",Author:"高鹗"}) return n;

create (n:Book{title:"藏山雷法",author:"",`Edition Language`:"Chinese"}) return n;


10.节点属性数据类型

create (x:Person{name:["孙悟空","齐天大圣"]}) return x;


11.通过属性搜索节点

match (n:Book{author:"abc"}) return n;

match (n:Book) where n.price < 1000 and (n.author = 'abc') return n;

match (n:Book) where toInt(n.pages) = 528 return n;


12.更新节点属性

match (n) where n.title = "xxx" set n.title="yyy" return n;

match (n:Book{title:"xxx"}) set n.title = "yyy" return n;

复制节点属性


13.删除节点属性


14.import csv


些的cypher语法

neo4j.com/developer/gui

相关文章