Neo4j CQL - CREATE

Neo4j CQL "CREATE" Command is used
To create Nodes without properties
To create Nodes without properties
To create Nodes with Properties
To create Nodes with Properties
To create Relationships between Nodes without Properties
To create Relationships between Nodes without Properties
To create Relationships between Nodes with Properties
To create Relationships between Nodes with Properties
To create single or multiple labels to a Node or a Relationship
To create single or multiple labels to a Node or a Relationship
We will discuss how to create a Node without Properties in this chapter. For other scenarios, please refer coming chapters
Neo4j CQL "CREATE" Command is used to create Node without properties. It just creates a Node without any data.
CREATE (<node-name>:<label-name>)
Syntax Description
Things to remember -
Neo4j Database Server uses this <node-name> to store this node details in Database.As a Neo4j DBA or Developer, we cannot use it to access node details.
Neo4j Database Server uses this <node-name> to store this node details in Database.As a Neo4j DBA or Developer, we cannot use it to access node details.
Neo4j Database Server creates a <label-name> as an alias to internal node name.As a Neo4j DBA or Developer, we should use this label name to access node details.
Neo4j Database Server creates a <label-name> as an alias to internal node name.As a Neo4j DBA or Developer, we should use this label name to access node details.
This Example demonstrates how to create a Simple "Employee" node.  Follow below steps:
Step 1 - Open Neo4j Data Browser
Step 2 - Type the below command at dollar prompt in Data Browser.
CREATE (emp:Employee)
Here emp is a node name
Employee is a label name for emp node
Step 3 - Click on Execute button and see the success message in the Data Browser.
It shows that one label and one node is created in Neo4j Database. 
It creates a Node "emp" with label name "Employee" in the Database.
This Example demonstrates how to create a Simple "Dept" node.  Follow below steps:
Step 1 - Open Neo4j Data Browser.
Step 2 - Type the below command at dollar prompt in Data Browser.
CREATE (dept:Dept)
Here dept is a node name
Dept is a label name for dept node
Step 3 - Click on Execute button and see the success message in the Data Browser.
It shows that one label and one node is created in Neo4j Database. It creates a Node "dept" with label name "Dept" in the Database.
Neo4j CQL "CREATE" Command is used to create Node with properties. It creates a Node with some properties(key-value pairs) to store data.
CREATE (
   <node-name>:<label-name>
   { 	
      <Property1-name>:<Property1-Value>
      ........
      <Propertyn-name>:<Propertyn-Value>
   }
)
Syntax Description
This Example is demonstrates how to create a Dept Node with some properties(deptno,dname,location).  Follow the below given steps -
Step 1 - Open Neo4j Data Browser.
Step 2 - Type the below command at dollar prompt in Data Browser.
CREATE (dept:Dept { deptno:10,dname:"Accounting",location:"Hyderabad" })
Here dept is a node name
Dept is a label name for emp node
Here Property names are deptno,dname,location
Property values are 10,"Accounting","Hyderabad"
As we discussed, Property a name-value pair.
Property = deptno:10
As deptno is a integer property so we have not used a single quote or double quotes to define its value 10.
As dname and location are of String type properties so we have used a single quote or double quotes to define its value 10.
NOTE - To define String type Property values, we need to use either single quote or double quotes.
Step 3 - Click on Execute button and see the success message in the Data Browser.
If you observe the success message, it tells us that
One Label is created i.e. "Dept"
One Node is created i.e. "dept"
Three Properties are created i.e.  deptno,dname,location
This Example is demonstrates how to create a Employee Node with some properties(id,name,sal,deptno). Follow the below given steps -
Step 1 - Open Neo4j Data Browser.
Step 2 - Type the below command at dollar prompt in Data Browser.
CREATE (emp:Employee{id:123,name:"Lokesh",sal:35000,deptno:10})
Here emp is a node name
Employee is a label name for dept node
Step 3 - Click on Execute button and see the success message in the Data Browser.
Observe successful message
Added 1 label, created 1 node, set 4 properties, returned 0 rows
This command has create one node "emp" with 4 properties ("id","name","sal","deptno") and assigned a label "Employee".
 Print
 Add Notes
 Bookmark this page