Open In App

Neo4j Create Node

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.

$ CREATE (a:GeeksforGeeks { Tag : "A Computer Science Portal" })

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.



$ CREATE (a:GeeksforGeeks { Tag : "A Computer Science Portal", Type : "Edutech" }) 
RETURN 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.

$ CREATE (a:GeeksforGeeks { Tag: "A Computer Science Portal"}), 
(b:W3School { Tag: "We are the Learner"}) 
RETURN a, b
CREATE (a:GeeksforGeeks { Tag: "A Computer Science Portal"}) 
CREATE (b:W3School { Tag: "We are the Learner"}) 
RETURN a, b

Note: Both the query will gave you same output.



Article Tags :