How to list all all graphs in Virtuoso?

▼魔方 西西 提交于 2019-12-06 14:10:26

As noted in comments, this query will get you a list of all Named Graphs (which, as also noted, are not the same as "namespaces") in the targeted store --

  SELECT  DISTINCT ?g 
   WHERE  { GRAPH ?g {?s ?p ?o} } 
ORDER BY  ?g

You can see live results (limited here to 100 graph names) on the DBpedia endpoint (a very short list, as you would expect) and on URIBurner (a much longer and more varied list).

I know this is an old question, but I was facing the same problem and thought someone else might benefit from the solution I found.

I was trying to execute this query to list all graphs and it was taking about 5 minutes to return a result:

SELECT DISTINCT ?g 
WHERE { 
  GRAPH ?g {?s ?p ?o}
} 

Instead, you should try the following query suggested in this documentation from Virtuoso:

SELECT DISTINCT ?g 
WHERE { 
  GRAPH ?g {?s a ?o}
} 

This query finished in less than 1 second and returned the list of graphs in the store. Of course, this query would only return graphs which have at least one triple with the predicate rdf:type, but it's still a big improvement on the one suggested by TallTed.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!