반응형

/*
-- Title : [Cypr] Create Node 구문
-- Tag : cypher node label create property
*/


■ 단일 노드 생성

ttt$ create (n)
Created 1 nodes, completed after 2 ms.

ttt$ match (n) return n
{
  "identity": 0,
  "labels": [],
  "properties": {

  }
}


■ 여러 노드 생성

ttt$ CREATE (n), (m)
Created 2 nodes, completed after 2 ms.

ttt$ match(n) return n
{
  "identity": 0,
  "labels": [],
  "properties": {

  }
}
{
  "identity": 1,
  "labels": [],
  "properties": {

  }
}
{
  "identity": 2,
  "labels": [],
  "properties": {

  }
}

 


■ 레이블이 있는 노드 생성

ttt$ CREATE (n:Person)
Added 1 label, created 1 node, completed after 6 ms.

ttt$ match(n:Person) return n
{
  "identity": 3,
  "labels": [
    "Person"
  ],
  "properties": {

  }
}


■ 여러 개의 레이블이 있는 노드 생성

ttt$ CREATE (n:Person:Swedish)
Added 2 labels, created 1 node, completed after 6 ms.

ttt$ match(a:Person:Swedish) return a
{
  "identity": 4,
  "labels": [
    "Person",
    "Swedish"
  ],
  "properties": {

  }
}


■ 레이블 및 속성이 있는 노드 추가

ttt$ CREATE (n:Person {name: 'Andy', title: 'Developer'})
Added 1 label, created 1 node, set 2 properties, completed after 6 ms.

ttt$ match(n:Person) where n.name = 'Andy' return n
{
  "identity": 5,
  "labels": [
    "Person"
  ],
  "properties": {
"name": "Andy",
"title": "Developer"
  }
}


■ 노드 생성 후 반환

ttt$ CREATE (a {name: 'Andy'}) RETURN a, a.name

│"a"            │"a.name"│
│{"name":"Andy"}│"Andy"  │

※ Resources
https://neo4j.com/docs/cypher-manual/current/clauses/create/

 

반응형

+ Recent posts