Virtuoso SPARQL 1.1. DROP Usage Examples

What?

This guide contains Virtuoso SPARQL 1.1. DROP Usage examples queries which you can run against any SPARQL endpoint that supports SPARQL 1.1 and the ability to allow a verified user perform INSERT operations.

Why?

Use to remove a named graph from the RDF Quad Store.

How?

Here are some examples showcasing Virtuoso's support for this functionality:

DROP Example

This example drops named graph identified by the IRI <urn:sparql:tests:drop:data> from the RDF Quad Store.

  1. Assume the following Raw Data Representation in Turtle:

    <#book1> <#price> 41 . <#book2> <#price> 42 . <#book3> <#price> 43 . <#book4> <#price> 44 .

  2. Create explicitly a named graph with IRI <urn:sparql:tests:drop:data> :

    CREATE GRAPH <urn:sparql:tests:drop:data>;

  3. Load the sample data:

    INSERT DATA { GRAPH <urn:sparql:tests:drop:data> { <#book1> <#price> 41 . <#book2> <#price> 42 . <#book3> <#price> 43 . <#book4> <#price> 44 . } }

  4. Query graph <urn:sparql:tests:drop:data> data -- should return 4 triples:

    SELECT * FROM <urn:sparql:tests:drop:data> WHERE { ?s ?p ?o }

  5. Drop the named graph identified by the IRI <urn:sparql:tests:drop:data> :

    DROP GRAPH <urn:sparql:tests:drop:data>;

    • Note: If the graph is not created explicitly as per above, i.e. the step CREATE GRAPH .. is omitted, in order to drop the graph you need to use SILENT option, which will not signal any errors:

      DROP SILENT GRAPH <urn:sparql:tests:drop:data>;

  6. Query graph <urn:sparql:tests:drop:data> data -- should return no triples:

    SELECT * FROM <urn:sparql:tests:drop:data> WHERE { ?s ?p ?o }

Related