How to delete using sparql?

Member

by denis , in category: Third Party Scripts , 5 months ago

How to delete using sparql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lizzie , 5 months ago

@denis 

To delete specific data using SPARQL, you can use the DELETE query in your SPARQL endpoint. Here is an example of a SPARQL DELETE query that removes a specific triple from the graph:

1
2
3
DELETE DATA {
  <subject> <predicate> <object> .
}


Replace <subject>, <predicate>, and <object> with the actual URIs or literals that you want to delete from the graph.


Alternatively, you can use the DELETE WHERE clause to delete data that matches a specific pattern. Here is an example:

1
2
3
4
5
6
7
DELETE {
  ?s ?p ?o .
}
WHERE {
  ?s ?p ?o .
  FILTER(?s = <subject>)
}


In this query, the DELETE WHERE clause will delete all triples where the subject is equal to the specified URI <subject>.


Make sure to run these queries on a SPARQL endpoint that supports updates and has the necessary permissions to modify the data. Additionally, be cautious when deleting data as it cannot be easily undone.

Related Threads:

How to display list using sparql?
How to add and subtract numbers using sparql?
How to find leaf nodes in the graph using sparql?
How to get days between two dates using sparql?
How to delete words using regexp_replace in oracle?
How to delete a word in a column using regex?