Virtuoso SPARQL 1.1. COPY Usage Examples

What?

This guide contains Virtuoso SPARQL 1.1. COPY 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 as shortcut for inserting all data from an input graph into a destination graph. Note that the original content in the destination graph is lost by a COPY operation.

How?

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

COPY Example

This example copies all triples from a named graph identified by the IRI <urn:sparql:tests:copy:data> to a named graph identified by the IRI <urn:sparql:tests:copy2:data>

  1. Assume the following Raw Data Representation in Turtle:

    <#book1> <#price> 41 . <#book2> <#price> 42 .

  2. Load the sample data into <urn:sparql:tests:copy:data>:

    INSERT DATA { GRAPH <urn:sparql:tests:copy:data> { <#book1> <#price> 41 . <#book2> <#price> 42 . } }

  3. Query graph <urn:sparql:tests:copy:data> data:

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

  4. Assume the following Raw Data Representation in Turtle:

    <#book3> <#price> 43 . <#book4> <#price> 44 .

  5. Load the sample data into <urn:sparql:tests:copy2:data>:

    INSERT DATA { GRAPH <urn:sparql:tests:copy2:data> { <#book3> <#price> 43 . <#book4> <#price> 44 . } }

  6. Query graph <urn:sparql:tests:copy2:data> data:

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

  7. Copy all triples from <urn:sparql:tests:copy:data> to <urn:sparql:tests:copy2:data>

    COPY <urn:sparql:tests:copy:data> TO <urn:sparql:tests:copy2:data>;

  8. Query graph <urn:sparql:tests:copy2:data> data: Note that the original content in <urn:sparql:tests:copy2:data> is lost by a COPY operation:

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

Related