Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Neo4j Create Node

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In the Neo4j to create node you will have to state CREATE statement. With the help of cypher language it is easy to create nodes, properties and relation between nodes. Let’s create sample node of GeeksforGeeks. You can see the table format, the actual code and the text also by selecting options. Below examples will illustrate the concept more clearly. Example: In this example we will create a node label “GeeksforGeeks” with the “Tag” property that will tell us about the “GeeksforGeeks” that will be property value.

  • To create the node:
$ CREATE (a:GeeksforGeeks { Tag : "A Computer Science Portal" })
  • The prefix a is a variable that will be anything this thing will required to refer later in any statement. After firing the Cypher query you will get something like the below picture. Output:

Display node: So now you have a created node but the above query does not show you the created node to see the node you need to use RETURN statement like have to fire the below query. Here again we will create a node with 2 properties.

  • Display Created node:
$ CREATE (a:GeeksforGeeks { Tag : "A Computer Science Portal", Type : "Edutech" }) 
  • Output: Note: We return the node by using its variable name (in this case a).

Creating multiple nodes: To create multiple nodes use the CREATE statement and separate the nodes by “, ” coma or you can use multiple time CREATE statement Like the below query.

  • Multiple nodes single Query using coma:
$ CREATE (a:GeeksforGeeks { Tag: "A Computer Science Portal"}), 
(b:W3School { Tag: "We are the Learner"}) 
  • or
CREATE (a:GeeksforGeeks { Tag: "A Computer Science Portal"}) 
CREATE (b:W3School { Tag: "We are the Learner"}) 
  • Output:

Note: Both the query will gave you same output.

My Personal Notes arrow_drop_up
Last Updated : 17 Nov, 2022
Like Article
Save Article
Similar Reads