LowFieldTheory
LowFieldTheory

Reputation: 1773

How do I get the already existing constraints in Neo4j?

When I've created some constraints on the graph, how is possible to see them and in case eliminate them? What is the syntax to treat them as elements of the graph?

Upvotes: 6

Views: 12605

Answers (6)

ino
ino

Reputation: 1125

In Neo4j 5.x.x, its SHOW CONSTRAINT command.

Upvotes: 6

Greg
Greg

Reputation: 1989

SHOW CONSTRAINTS

I was able to get existing constraints with the above using the neo4j:5-community Docker image.

Upvotes: 2

HyperActive
HyperActive

Reputation: 1326

to do this in cypher you can execute

CALL db.constraints;

which gives a table of constraints from which you can delete entries by referencing the name column when executing

DROP CONSTRAINT constraint_name;

Upvotes: 7

James Valentine
James Valentine

Reputation: 11

Running

call db.schemaStatements()

seems to give the constraints along with the syntax of the DROP statement as well, ready to copy/paste, for example:

DROP CONSTRAINT `publisher_id`

Upvotes: 1

Akshay Tenkale
Akshay Tenkale

Reputation: 161

In Browser you can use CALL db.constraints to get all constraints on graph.

For more Info: https://neo4j.com/docs/developer-manual/current/cypher/schema/constraints/

Upvotes: 7

Michael Hunger
Michael Hunger

Reputation: 41706

In the neo4j browser you can use the :schema command to list them. In shell it is schema

Then you can remove them with

`DROP INDEX ON :Label(prop)` 

or

`DROP CONSTRAINT ON (n:Label) ASSERT n.props IS UNIQUE`

Upvotes: 7

Related Questions