Reputation: 5
How can I check the existing CONSTRAINTS in neo4j.
For example I have created one constraint like
CREATE CONSTRAINT ON (m:BBG_Security_DATA) ASSERT m.ISIN IS UNIQUE;
Before re-create the same constraint I have to re-check.
Thanks in advance.
Regards, Shafeeque
Upvotes: 0
Views: 1625
Reputation: 3238
Neo4j does not complain if you CREATE the same constraint multiple times - returns (no changes, no records)
in the browser.
It does complain if you try to DROP a constraint that does not exist. As noted in this SO answer (from comment above), you can use:
CALL db.constraints
to get a current list constraints and decide which need to be dropped.
══════════════════════════════════════════════════════════════════════╕
│"description" │
╞══════════════════════════════════════════════════════════════════════╡
│"CONSTRAINT ON ( c:Classification ) ASSERT c.id IS UNIQUE" │
├──────────────────────────────────────────────────────────────────────┤
│"CONSTRAINT ON ( d:Directory ) ASSERT d.id IS UNIQUE" │
├──────────────────────────────────────────────────────────────────────┤
│"CONSTRAINT ON ( f:File ) ASSERT f.id IS UNIQUE" │
├──────────────────────────────────────────────────────────────────────┤
│"CONSTRAINT ON ( p:Perspective ) ASSERT p.id IS UNIQUE" │
└──────────────────────────────────────────────────────────────────────┘
Upvotes: 1