Skip to content
Related Articles

Related Articles

Neo4j Create Node
  • Last Updated : 23 Aug, 2019

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 GeeksforGeesk. 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.

    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:GeksforGeeks { Tag : "A Computer Science Portal", Type : "Edutech" }) 
    RETURN a


    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"}) 
    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.

    Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

    My Personal Notes arrow_drop_up
  • Recommended Articles
    Page :