how can I quickly drop thousands of named graphs?

162 views
Skip to first unread message

Peter Neorr

unread,
Mar 8, 2016, 2:15:48 AM3/8/16
to Stardog
Hello All,

What is the best way to quickly drop a lot named graphs?  I'm using the sesame API and sparql to select all the graphs I want to delete, but then I'm removing them by iterating through a bunch of separate "drop graph <XXX>" queries.  Is there a better way to do this?  Some sparql magic I'm not aware of perhaps?

Regards,
Peter Neorr

Pavel Klinov

unread,
Mar 8, 2016, 3:39:05 AM3/8/16
to sta...@clarkparsia.com
Hi Peter,

To delete a named graph from a Stardog database, it is sufficient to delete all quads which belong to it. You can remove all quads from more than one graph using a single SPARQL Update query, for example:

DELETE { graph ?g { ?s ?p ?o } } 

WHERE {

graph ?g {?s ?p ?o.}

VALUES ?g { <urn:g1> <urn:g2> }

}

Here I hardcoded two graph IRIs but you're free to use any graph pattern which binds ?g. In particular, you can use the SPARQL query which you use separately to prepare the list of graphs to delete.

Cheers,
Pavel

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Peter Neorr

unread,
Mar 9, 2016, 12:08:06 AM3/9/16
to sta...@clarkparsia.com
This is exactly what I needed to know. Thank you Pavel!
-P

---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.
Reply all
Reply to author
Forward
0 new messages