SPARQL Queries

What’s in this document?

To manage and query your data, go to the SPARQL menu tab. The SPARQL view integrates the YASGUI query editor plus some additional features, which are described below.


SPARQL is a SQL-like query language for RDF graph databases with the following types:

  • SELECT - returns tabular results;

  • CONSTRUCT - creates a new RDF graph based on query results;

  • ASK - returns “YES” if the query has a solution, otherwise “NO”;

  • DESCRIBE - returns RDF data about a resource; useful when you do not know the RDF data structure in the data source;

  • INSERT - inserts triples into a graph;

  • DELETE - deletes triples from a graph.

The SPARQL editor offers two viewing/editing modes - horizontal and vertical.


Use the vertical mode switch to show the editor and the results next to each other, which is particularly useful on wide screen. Click the switch again to return to horizontal mode.


Both in horizontal and vertical mode, you can also hide the editor or the results to focus on query editing or result viewing. Click the buttons Editor only, Editor and results, or Results only to switch between the different modes.

  1. Manage your data by writing queries in the text area. It offers syntax highlighting and namespace autocompletion for easy reading and writing.


    To add/remove namespaces, go to Setup ‣ Namespaces.

  2. Include or exclude inferred statements in the results by clicking the >> icon. When inferred statements are included, both elements of the arrow icon are a solid line (ON), otherwise the left element is a solid line and the right one is a dotted line. (OFF).

  3. Enable or disable the expanding of the results over owl:sameAs by clicking the last icon above the Run button. Similarly to the one above it, the setting is ON when all its three circles are a solid line, and OFF when two of them are a dotted one.

  4. Execute the query by clicking the Run button or use Ctrl/Cmd + Enter.


    You can find other useful shortcuts in the keyboard shortcuts link in the lower right corner of the SPARQL editor.

  5. The results can be viewed in different formats corresponding to the type of the query. By default, they are displayed as a table. Other options are Raw response, Pivot table and Google Charts. You can order the results by column values and filter them by table values. The total number of results and the query execution time are displayed in the query results header.


    The total number of results is obtained by an async request with a default-graph-uri parameter and the value

  6. Navigate through all results by using pagination (SPARQL view can only show a limited number of results at a time). Each page executes the query again with query limit and offset for SELECT queries. For graph queries (CONSTRUCT and DESCRIBE), all results are fetched by the server and only the page of interest is gathered from the results iterator and sent to the client.

  7. The query results are limited to 1,000, since your browser cannot handle an infinite number of results. Obtain all results by using Download As and select the required format for the data (JSON, XML, CSV, TSV and Binary RDF for SELECT queries and all supported RDF formats for CONSTRUCT and DESCRIBE query results).

Save and share queries

Use the editor’s tabs to keep several queries opened while working with GraphDB. Save a query on the server with the Create saved query icon.


When security is ON in the Setup ‣ Users and Access menu, the system distinguishes between different users. The user can choose whether to share a query with others, and shared queries are editable by the owner only.

Access existing queries (default, yours, and shared) from the Show saved queries icon.


Copy your query as a URL by clicking the Get URL to current query icon.

When Free access is ON, the Free Access user will see shared queries only and will not be able to save new queries.

Interrupt queries

You can use the Abort query button in the SPARQL editor to manually interrupt any query.