GRAPH.CONSTRAINT DROP
syntax: |
GRAPH.CONSTRAINT DROP key
MANDATORY|UNIQUE
NODE label | RELATIONSHIP reltype
PROPERTIES propCount prop [prop…]
—
Deleted a graph constraint.
For an introduction to constraints see GRAPH.CONSTRAINT CREATE
Required arguments
key
is key name for the graph.
constraintType
is the constraint type: either `MANDATORY` or `UNIQUE`.
NODE label | RELATIONSHIP reltype
is the graph entity type (`NODE` or `RELATIONSHIP`) and the name of the node label or relationship type on which the constraint is enforced.
propCount
is the number of properties following. Valid values are between 1 and 255.
prop...
is a list of `propCount` property names.
Return value
@simple-string-reply - OK if executed correctly, or @error-reply otherwise.
Examples
To delete a unique constraint for all nodes with label Person enforcing uniqueness on the combination of values of attributes first_name and last_name, issue the following command:
from falkordb import FalkorDB
client = FalkorDB()
result = client.drop_constraint('g', 'UNIQUE', 'NODE', 'Person', ['first_name', 'last_name'])
print(result)
import { FalkorDB } from 'falkordb';
const client = await FalkorDB.connect();
const result = await client.dropConstraint('g', 'UNIQUE', 'NODE', 'Person', ['first_name', 'last_name']);
console.log(result);
let client = FalkorDB::connect_default();
let result = client.drop_constraint("g", "UNIQUE", "NODE", "Person", &["first_name", "last_name"])?;
println!("{}", result);
FalkorDB client = new FalkorDB();
String result = client.dropConstraint("g", "UNIQUE", "NODE", "Person", Arrays.asList("first_name", "last_name"));
System.out.println(result);
redis> GRAPH.CONSTRAINT DROP g UNIQUE NODE Person PROPERTIES 2 first_name last_name
# Output: OK
Frequently Asked Questions 4
Is dropping a constraint synchronous or asynchronous?
Unlike constraint creation, dropping a constraint is synchronous. The command returns OK immediately upon successful removal.
Do I need to drop the supporting index after dropping a unique constraint?
No, the supporting index is not automatically removed. You can drop it separately if it is no longer needed, but it may still be useful for query performance.
What happens if I try to drop a constraint that does not exist?
The command will return an error indicating that the specified constraint was not found.
Does dropping a constraint affect existing data?
No. Dropping a constraint only removes the enforcement rule. Existing data remains unchanged; it simply will no longer be validated against that constraint.