<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://techbase.kde.org/skins/common/feed.css?0.2"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://techbase.kde.org/index.php?title=Projects/Nepomuk/VirtuosoInternal/en&amp;feed=atom&amp;action=history</id>
		<title>Projects/Nepomuk/VirtuosoInternal/en - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://techbase.kde.org/index.php?title=Projects/Nepomuk/VirtuosoInternal/en&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/index.php?title=Projects/Nepomuk/VirtuosoInternal/en&amp;action=history"/>
		<updated>2013-05-25T19:55:54Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.2</generator>

	<entry>
		<id>http://techbase.kde.org/index.php?title=Projects/Nepomuk/VirtuosoInternal/en&amp;diff=77248&amp;oldid=prev</id>
		<title>FuzzyBot: Updating to match new version of source page</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/index.php?title=Projects/Nepomuk/VirtuosoInternal/en&amp;diff=77248&amp;oldid=prev"/>
				<updated>2012-12-13T16:42:14Z</updated>
		
		<summary type="html">&lt;p&gt;Updating to match new version of source page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Connecting directly to virtuoso ==&lt;br /&gt;
&lt;br /&gt;
Virtuoso ships with an executable called &amp;lt;tt&amp;gt;isql-vt&amp;lt;/tt&amp;gt;. Just running that executable should connect you to virtuoso.&lt;br /&gt;
&lt;br /&gt;
If you distribution does not provide the corresponding executable or if it doesn't work for you. Try this script -&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
filename=`ps aux | grep virtuoso-t | grep -v grep | sed -e 's/.*\/tmp\///;s/ini.*/ini/'`&lt;br /&gt;
port=$(grep ServerPort /tmp/$filename | sed -e 's/.*=//')&lt;br /&gt;
exec isql-vt -S $port&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running queries directly ==&lt;br /&gt;
&lt;br /&gt;
If for some reason you want to run queries directly on virtuoso, you'll need to connect to virtuoso via &amp;lt;tt&amp;gt;isql-vt&amp;lt;/tt&amp;gt; and then type in the query. From 4.10, we use virtuoso's inbuilt prefix expansion, so you don't need to care about the prefixes.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
SQL&amp;gt; sparql select ?r ?name where { ?r nco:fullname ?name . };&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List of tables ==&lt;br /&gt;
&lt;br /&gt;
Virtuoso internally uses a relational database to store the triples. It contains the following tables -&lt;br /&gt;
&lt;br /&gt;
* DB.DBA.RDF_QUAD -- The main table which contains all the statements. It contains four rows &amp;quot;S&amp;quot;, &amp;quot;P&amp;quot;, &amp;quot;O&amp;quot; and &amp;quot;G&amp;quot; for the subject, predicate, object and graph.&lt;br /&gt;
* DB.DBA.RDF_IRI&lt;br /&gt;
* DB.DBA.RDF_DATATYPE - Contains all the literal data types which are stored.&lt;br /&gt;
* DB.DBA.RDF_PREFIX&lt;br /&gt;
* DB.DBA.RDF_OBJ&lt;br /&gt;
* DB.DBA.RDF_LANGUAGE&lt;br /&gt;
&lt;br /&gt;
Read http://docs.openlinksw.com/virtuoso/rdfdatarepresentation.html to properly understand how virtuoso stores the data internally.&lt;br /&gt;
&lt;br /&gt;
Virtuoso has 2 main types - IRI_ID, which is the data type of the graph, subject and predicate. IRI_ID are of the form &amp;quot;#i25&amp;quot;. In order to convert an integer to an IRI_ID, use the '''iri_id_from_num( int )''' function, and the '''iri_id_num( iri_id )''' to convert an IRI_ID to an integer. In order to convert an IRI_ID to its string representation use the following functions '''id_to_iri( iri_id, int )''', and '''iri_to_id( string, int )'''. The second integer option should be 0, unless you want the iri/id to be created if it doesn't exist.&lt;br /&gt;
&lt;br /&gt;
== Default Indexes ==&lt;br /&gt;
&lt;br /&gt;
== Common Commands ==&lt;br /&gt;
&lt;br /&gt;
Apart from directly running SQL and SPARQL queries, virtuoso also provides some additional commands, which are listed over here.&lt;br /&gt;
&lt;br /&gt;
=== status ===&lt;br /&gt;
The [http://docs.openlinksw.com/virtuoso/fn_status.html status()] function can be used to return the current running queries on virtuoso.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== sparql_to_sql_text ===&lt;br /&gt;
&lt;br /&gt;
The [http://docs.openlinksw.com/virtuoso/fn_sparql_to_sql_text.html sparql_to_sql_text()] function can be used to convert a SPARQL query directly to the SQL it would be executed as.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
varchar sparql_to_sql_text&lt;br /&gt;
( in squery varchar ); &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example -&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
SQL&amp;gt; select sparql_to_sql_text('prefix nco: &amp;lt;http://www.semanticdesktop.org/ontologies/2007/03/22/nco#&amp;gt; select ?r ?name where { ?r nco:fullname ?name . }');&lt;br /&gt;
SPARQL_TO_SQL_TEXT&lt;br /&gt;
VARCHAR&lt;br /&gt;
_______________________________________________________________________________&lt;br /&gt;
&lt;br /&gt;
SELECT __id2i ( &amp;quot;s_1_0-t0&amp;quot;.&amp;quot;S&amp;quot; ) AS &amp;quot;r&amp;quot;,&lt;br /&gt;
  __ro2sq ( &amp;quot;s_1_0-t0&amp;quot;.&amp;quot;O&amp;quot; ) AS &amp;quot;name&amp;quot;&lt;br /&gt;
FROM DB.DBA.RDF_QUAD AS &amp;quot;s_1_0-t0&amp;quot;&lt;br /&gt;
WHERE &amp;quot;s_1_0-t0&amp;quot;.&amp;quot;P&amp;quot; = __i2idn ( __bft( 'http://www.semanticdesktop.org/ontologies/2007/03/22/nco#fullname' , 1))&lt;br /&gt;
OPTION (QUIETCAST)&lt;br /&gt;
&lt;br /&gt;
1 Rows. -- 1 msec.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It's very useful in debugging why many sparql queries are taking so long.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>	</entry>

	</feed>