Commands Cheat Sheet

Evaluating engineering tools? Get the comparison in Google Sheets

(Perfect for making buy/build decisions or internal reviews.)

Most-used commands
Your email is safe thing.

Thankyou for your submission

We have sent the cheatsheet on your email!
Oops! Something went wrong while submitting the form.

Connection

Use Neo4j Browser
Web-based interface at http://localhost:7474 by default

Connection string
neo4j://localhost:7687

Connect in Cypher Shell
cypher-shell -a neo4j://localhost:7687 -u username -p password

Connect via driver
Common pattern in programming languages to connect with credentials

Database Operations

Show databases
SHOW DATABASES

Create database
CREATE DATABASE name

Drop database
DROP DATABASE name

Use database
:use name

Schema Operations

Show constraints
SHOW CONSTRAINTS

Create constraint
CREATE CONSTRAINT constraint_name FOR (n:Label) REQUIRE n.property IS UNIQUE

Show indexes
SHOW INDEXES

Create index
CREATE INDEX index_name FOR (n:Label) ON (n.property)

Node Operations

Create node
CREATE (n:Label {property: 'value'})

Match node
MATCH (n:Label {property: 'value'}) RETURN n

Update node
MATCH (n:Label {property: 'value'}) SET n.property2 = 'newValue'

Delete node
MATCH (n:Label {property: 'value'}) DELETE n

Relationship Operations

Create relationship
MATCH (a:Label1), (b:Label2) CREATE (a)-[:RELATIONSHIP]->(b)

Match relationship
MATCH (a)-[r:RELATIONSHIP]->(b) RETURN a,r,b

Update relationship
MATCH (a)-[r:RELATIONSHIP]->(b) SET r.property = 'value'

Delete relationship
MATCH (a)-[r:RELATIONSHIP]->(b) DELETE r

Query Operations

Count nodes
MATCH (n:Label) RETURN count(n)

Limit results
MATCH (n) RETURN n LIMIT 10

Order results
MATCH (n) RETURN n ORDER BY n.property

Aggregate data
MATCH (n:Label) RETURN n.property, count(*)

Graph Algorithms

Shortest path
MATCH p=shortestPath((a:Label1)-[*]-(b:Label2)) RETURN p

All paths
MATCH p=(a:Label1)-[*..5]->(b:Label2) RETURN p

System Commands

:help
Show help menu in Neo4j Browser

:play
Open interactive guides

:sysinfo
Show system information

:schema
Display database schema information

Performance

EXPLAIN
EXPLAIN MATCH (n) RETURN n

PROFILE
PROFILE MATCH (n) RETURN n

Admin Commands

List users
SHOW USERS

Create user
CREATE USER username SET PASSWORD 'password'

Grant role
GRANT ROLE admin TO username