neo4j

Create one or multiple nodes Cypher query neo4j

Here we will learn to create one or multiple nodes in the neo4j graph database using Cypher queries.

// Create single node
CREATE (n)

// Create more than one node
CREATE (n), (m)
Output
You can create single or multiple nodes in the neo4j database using the above queries. The first Cypher query will create a single node in the database and the second Cypher query will create two nodes in the neo4j graph database.
CREATE (a), (b)
The above Cypher query can be used to create multiple nodes in neo4j graph database.
CREATE (n:Employee)
The above Cypher query can be used to create a node with the label. We will call that node labeled node. Here we are creating a node which contains a label Employee
CREATE (n:Employee:Programmer)
This is the Cypher query to create a node that contains multiple labels. In the above Cypher query we are creating a node that has two labels - Employee and Programmer
CREATE (n:Employee {name: 'Ankit', title: 'Programmer', company: 'Devsheet'})
We can add properties to a node while creating it using the Cypher query. The above query will do the same. Here, we are creating a node with the label Employee and adding properties to it like name, title, and company.
CREATE (n:Employee {name: 'John Deo'})
RETURN n
After a node is created it can also be returned using the same Cypher query that is used to create it. The above Cypher query is creating a new node with label Employe and also name property is also added while creating it.
Was this helpful?