| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| |
| |
| <title>Apache Jena - SDB/Commands</title> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <link href="/css/bootstrap.min.css" rel="stylesheet" media="screen"> |
| <link href="/css/bootstrap-extension.css" rel="stylesheet" type="text/css"> |
| <link href="/css/jena.css" rel="stylesheet" type="text/css"> |
| <link rel="shortcut icon" href="/images/favicon.ico" /> |
| |
| <script src="https://code.jquery.com/jquery-2.2.4.min.js" |
| integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" |
| crossorigin="anonymous"></script> |
| <script src="/js/jena-navigation.js" type="text/javascript"></script> |
| <script src="/js/bootstrap.min.js" type="text/javascript"></script> |
| |
| <script src="/js/improve.js" type="text/javascript"></script> |
| |
| |
| </head> |
| |
| <body> |
| |
| <nav class="navbar navbar-default" role="navigation"> |
| <div class="container"> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <a class="navbar-brand" href="/index.html"> |
| <img class="logo-menu" src="/images/jena-logo/jena-logo-notext-small.png" alt="jena logo">Apache Jena</a> |
| </div> |
| |
| <div class="collapse navbar-collapse navbar-ex1-collapse"> |
| <ul class="nav navbar-nav"> |
| <li id="homepage"><a href="/index.html"><span class="glyphicon glyphicon-home"></span> Home</a></li> |
| <li id="download"><a href="/download/index.cgi"><span class="glyphicon glyphicon-download-alt"></span> Download</a></li> |
| <li class="dropdown"> |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-book"></span> Learn <b class="caret"></b></a> |
| <ul class="dropdown-menu"> |
| <li class="dropdown-header">Tutorials</li> |
| <li><a href="/tutorials/index.html">Overview</a></li> |
| <li><a href="/documentation/fuseki2/index.html">Fuseki Triplestore</a></li> |
| <li><a href="/documentation/notes/index.html">How-To's</a></li> |
| <li><a href="/documentation/query/manipulating_sparql_using_arq.html">Manipulating SPARQL using ARQ</a></li> |
| <li><a href="/tutorials/rdf_api.html">RDF core API tutorial</a></li> |
| <li><a href="/tutorials/sparql.html">SPARQL tutorial</a></li> |
| <li><a href="/tutorials/using_jena_with_eclipse.html">Using Jena with Eclipse</a></li> |
| <li class="divider"></li> |
| <li class="dropdown-header">References</li> |
| <li><a href="/documentation/index.html">Overview</a></li> |
| <li><a href="/documentation/query/index.html">ARQ (SPARQL)</a></li> |
| <li><a href="/documentation/assembler/index.html">Assembler</a></li> |
| <li><a href="/documentation/tools/index.html">Command-line tools</a></li> |
| <li><a href="/documentation/rdfs/">Data with RDFS Inferencing</a></li> |
| <li><a href="/documentation/geosparql/index.html">GeoSPARQL</a></li> |
| <li><a href="/documentation/inference/index.html">Inference API</a></li> |
| <li><a href="/documentation/javadoc.html">Javadoc</a></li> |
| <li><a href="/documentation/ontology/">Ontology API</a></li> |
| <li><a href="/documentation/permissions/index.html">Permissions</a></li> |
| <li><a href="/documentation/extras/querybuilder/index.html">Query Builder</a></li> |
| <li><a href="/documentation/rdf/index.html">RDF API</a></li> |
| <li><a href="/documentation/rdfconnection/">RDF Connection - SPARQL API</a></li> |
| <li><a href="/documentation/io/">RDF I/O</a></li> |
| <li><a href="/documentation/rdfstar/index.html">RDF-star</a></li> |
| <li><a href="/documentation/shacl/index.html">SHACL</a></li> |
| <li><a href="/documentation/shex/index.html">ShEx</a></li> |
| <li><a href="/documentation/jdbc/index.html">SPARQL over JDBC</a></li> |
| <li><a href="/documentation/tdb/index.html">TDB</a></li> |
| <li><a href="/documentation/tdb2/index.html">TDB2</a></li> |
| <li><a href="/documentation/query/text-query.html">Text Search</a></li> |
| </ul> |
| </li> |
| |
| <li class="drop down"> |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-book"></span> Javadoc <b class="caret"></b></a> |
| <ul class="dropdown-menu"> |
| <li><a href="/documentation/javadoc.html">All Javadoc</a></li> |
| <li><a href="/documentation/javadoc/arq/">ARQ</a></li> |
| <li><a href="/documentation/javadoc_elephas.html">Elephas</a></li> |
| <li><a href="/documentation/javadoc/fuseki2/">Fuseki</a></li> |
| <li><a href="/documentation/javadoc/geosparql/">GeoSPARQL</a></li> |
| <li><a href="/documentation/javadoc/jdbc/">JDBC</a></li> |
| <li><a href="/documentation/javadoc/jena/">Jena Core</a></li> |
| <li><a href="/documentation/javadoc/permissions/">Permissions</a></li> |
| <li><a href="/documentation/javadoc/extras/querybuilder/">Query Builder</a></li> |
| <li><a href="/documentation/javadoc/shacl/">SHACL</a></li> |
| <li><a href="/documentation/javadoc/tdb/">TDB</a></li> |
| <li><a href="/documentation/javadoc/text/">Text Search</a></li> |
| </ul> |
| </li> |
| |
| <li id="ask"><a href="/help_and_support/index.html"><span class="glyphicon glyphicon-question-sign"></span> Ask</a></li> |
| |
| <li class="dropdown"> |
| <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-bullhorn"></span> Get involved <b class="caret"></b></a> |
| <ul class="dropdown-menu"> |
| <li><a href="/getting_involved/index.html">Contribute</a></li> |
| <li><a href="/help_and_support/bugs_and_suggestions.html">Report a bug</a></li> |
| <li class="divider"></li> |
| <li class="dropdown-header">Project</li> |
| <li><a href="/about_jena/about.html">About Jena</a></li> |
| <li><a href="/about_jena/architecture.html">Architecture</a></li> |
| <li><a href="/about_jena/citing.html">Citing</a></li> |
| <li><a href="/about_jena/team.html">Project team</a></li> |
| <li><a href="/about_jena/contributions.html">Related projects</a></li> |
| <li><a href="/about_jena/roadmap.html">Roadmap</a></li> |
| <li class="divider"></li> |
| <li class="dropdown-header">ASF</li> |
| <li><a href="http://www.apache.org/">Apache Software Foundation</a></li> |
| <li><a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li> |
| <li><a href="http://www.apache.org/licenses/LICENSE-2.0">License</a></li> |
| <li><a href="http://www.apache.org/security/">Security</a></li> |
| <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| </ul> |
| </li> |
| |
| |
| |
| |
| <li id="edit"><a href="https://github.com/apache/jena-site/edit/main/source/documentation/archive/sdb/commands.md" title="Edit this page on GitHub"><span class="glyphicon glyphicon-pencil"></span> Edit this page</a></li> |
| </ul> |
| </div> |
| </div> |
| </nav> |
| |
| |
| <div class="container"> |
| <div class="row"> |
| <div class="col-md-12"> |
| <div id="breadcrumbs"> |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| <ol class="breadcrumb">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| <li><a href='/documentation'>DOCUMENTATION</a></li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| <li><a href='/documentation/archive'>ARCHIVE</a></li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| <li><a href='/documentation/archive/sdb'>SDB</a></li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| <li class="active">COMMANDS</li>
|
|
|
|
|
|
|
|
|
| </ol>
|
|
|
|
|
|
|
| |
| |
| </div> |
| <h1 class="title">SDB/Commands</h1> |
| |
| <p>This page describes the command line programs that can be used to |
| create an SDB store, load data into it and to issue queries.</p> |
| <h2 id="contents">Contents</h2> |
| <ul> |
| <li> |
| <p><a href="#scripts">Scripts</a></p> |
| <ul> |
| <li><a href="#script-set-up">Script set up</a></li> |
| <li><a href="#argument-structure">Argument Structure</a></li> |
| </ul> |
| </li> |
| <li> |
| <p><a href="#store-description">Store Description</a></p> |
| <ul> |
| <li><a href="#modifying-the-store-description">Modifying the Store Description</a></li> |
| <li><a href="#logging-and-monitoring">Logging and Monitoring</a></li> |
| </ul> |
| </li> |
| <li> |
| <p><a href="#sdb-commands">SDB Commands</a></p> |
| <ul> |
| <li><a href="#database-creation">Database creation</a></li> |
| <li><a href="#loading-data">Loading data</a></li> |
| <li><a href="#query">Query</a></li> |
| <li><a href="#testing">Testing</a></li> |
| <li><a href="#other">Other</a></li> |
| </ul> |
| </li> |
| </ul> |
| <h2 id="scripts">Scripts</h2> |
| <p>The directory <code>bin/</code> contains shell scripts to run the commands |
| from the command line. The scripts are bash scripts which also run |
| over <a href="http://www.cygwin.com/" title="http://www.cygwin.com/">Cygwin</a>.</p> |
| <h3 id="script-set-up">Script set up</h3> |
| <p>Set the environment variable <code>SDBROOT</code> to the root of the SDB |
| installation.</p> |
| <p>A store description can include naming the class for the JDBC |
| driver. Getting a <code>Store</code> object from a store description will |
| automatically load the JDBC driver from the classpath.</p> |
| <p>When running scripts, set the environment variable <code>SDB_JDBC</code> to |
| one or more jar files for JDBC drivers. If it is more than one jar |
| file, use the classpath syntax for your system. You can also use |
| the system property <code>jdbc.drivers</code>.</p> |
| <p>Set the environment variables <code>SDB_USER</code> and <code>SDB_PASSWORD</code> to the |
| database user name and password for JDBC.</p> |
| <pre><code> $ export SDBROOT="/path/to/sdb |
| $ export SDB_USER="YourDbUserName" |
| $ export SDB_PASSWORD="YourDbPassword" |
| $ export SDB_JDBC="/path/to/driver.jar" |
| </code></pre> |
| <p>They are bash scripts, and work on Linux and Cygwin for MS |
| Windows.</p> |
| <pre><code> $ export PATH=$SDBROOT/bin:$PATH |
| </code></pre> |
| <p>Alternatively, there are wrapper scripts in <code>$SDBROOT/bin2</code> which |
| can be placed in a convenient directory that is already on the |
| shell command path.</p> |
| <h3 id="argument-structure">Argument Structure</h3> |
| <p>All commands take a SDB store description to extract the connection |
| and configuration information they need. This is written |
| <em><code>SPEC</code></em> in the command descriptions below but it can be |
| composed of several arguments as described here.</p> |
| <p>Each command then has command-specific arguments described below.</p> |
| <p>All commands support <code>--help</code> to give details of named and |
| positional arguments.</p> |
| <p>There are two equivalent forms of named argument syntax:</p> |
| <pre><code>--arg=val |
| |
| --arg val |
| </code></pre> |
| <h2 id="store-description">Store Description</h2> |
| <p>If this is not specified, commands load the description file |
| sdb.ttl from the current directory.</p> |
| <pre><code> --sdb=<sdb.ttl> |
| </code></pre> |
| <p>This store description is a |
| <a href="/documentation/assembler/">Jena assembler</a> |
| file. The description consists of two parts; a store description |
| and a connection description.</p> |
| <p>Often, this is all that is needed to describe which store to use. |
| The individual components of a connection or configuration can be |
| overridden after the description have been read, before it is |
| processed.</p> |
| <p>The directory <code>Store/</code> has example assembler files.</p> |
| <p>The full details of the assembler file is given in |
| ‘<a href="store_description.html" title="SDB/Store Description">SDB/Store Description</a>’</p> |
| <h3 id="modifying-the-store-description">Modifying the Store Description</h3> |
| <p>The individual items of a store description can be overridden by |
| various command arguments. The description in the assembler file is |
| read, then any command line arguments used to modify the |
| description, then the appropriate object is created from the |
| modified description.</p> |
| <p>Set the layout type:</p> |
| <pre><code> --layout : layout name |
| </code></pre> |
| <p>Currently, one of <code>layout1</code>, <code>layout2</code>, <code>layout2/index</code>, |
| <code>layout2/hash</code>.</p> |
| <p>Set JDBC details:</p> |
| <pre><code> --dbName : Database Name |
| --dbHost : Host machine name |
| --dbType : Database type. |
| --dbUser : Database use |
| --dbPassword : Database password. |
| </code></pre> |
| <p>The host name can <code>host</code> or <code>host:port</code>.</p> |
| <p>The better way to handle passwords is to use environment variables |
| SDB_USER and SDB_PASSWORD because then the user/password is not |
| stored in a visible way.</p> |
| <h3 id="logging-and-monitoring">Logging and Monitoring</h3> |
| <p>All commands take the following arguments (although they may do |
| nothing if they make no sense to the command).</p> |
| <pre><code> -v |
| </code></pre> |
| <p>Be verbose.</p> |
| <pre><code> --time |
| </code></pre> |
| <p>Print timing information. Treat with care - while the timer avoids |
| recording JVM and some class loading time, it can’t avoid all class |
| loading. Hence, the values of timing are more meaningful on longer |
| operations. JDBC operation times to a remote server can also be a |
| significant proportion in short operations.</p> |
| <pre><code> --log=[all|none|queries|statements|exceptions] |
| </code></pre> |
| <p>to log SQL actions on the database connection (but not the prepared |
| statements used by the loader). Can be repeated on the command |
| line.</p> |
| <h2 id="sdb-commands">SDB Commands</h2> |
| <h3 id="database-creation">Database creation</h3> |
| <pre><code> sdbconfig SPEC [--create|--format|--indexes|--dropIndexes] |
| </code></pre> |
| <p>Setup a database.</p> |
| <table> |
| <thead> |
| <tr> |
| <th>Option</th> |
| <th>Description</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>--create</code></td> |
| <td>formats the store and sets up indexes</td> |
| </tr> |
| <tr> |
| <td><code>--format</code></td> |
| <td>just formats the store and creates indexes for loading, not querying.</td> |
| </tr> |
| <tr> |
| <td><code>--indexes</code></td> |
| <td>Create indexes for querying</td> |
| </tr> |
| <tr> |
| <td><code>--dropIndexes</code> </td> |
| <td>Drop indexes for querying.</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>Loading large graphs can be faster by formatting, loading the data, |
| then building the query indexes with this command.</p> |
| <pre><code> sdbtruncate SPEC |
| </code></pre> |
| <p>Truncate the store. Non-transactional. Destroys data.</p> |
| <h3 id="loading-data">Loading data</h3> |
| <pre><code> sdbload SPEC FILE [FILE ...] |
| </code></pre> |
| <p>Load RDF data into a store using the SDB bulk loader. Data is |
| streamed into the database and is not loaded as a single |
| transaction.</p> |
| <p>The file’s extension is used to determine the data syntax.</p> |
| <p>To load into a named graph:</p> |
| <pre><code> sdbload SPEC --graph=URI FILE [FILE ...] |
| </code></pre> |
| <h3 id="query">Query</h3> |
| <pre><code> sdbquery SPEC --query=FILE |
| </code></pre> |
| <p>Execute a query.</p> |
| <pre><code> sdbprint SPEC --print=X [--sql] --query=FILE |
| </code></pre> |
| <p>Print details of a query. <code>X</code> is any of <code>query</code>, <code>op</code>, <code>sqlNode</code>, |
| <code>sql</code> or <code>plan</code>. <code>--print=X</code> can be repeated. –sql is short for |
| –print=sql. The default is <code>--print=sql</code>.</p> |
| <h3 id="testing">Testing</h3> |
| <pre><code> sdbtest SPEC MANIFEST |
| </code></pre> |
| <p>Execute a test manifest file. The manifest of all query tests, |
| which will test connection and loading of data, is in |
| <code><em>SDBROOT</em>/testing/manifest-sdb.ttl</code>.</p> |
| <h3 id="other">Other</h3> |
| <pre><code> sdbdump SPEC --out=SYNTAX |
| </code></pre> |
| <p>Dump the contents of a store N-TRIPLES or a given serialization |
| format (usual Jena syntax names, e.g. <code>Turtle</code> or <code>TTL</code>).</p> |
| <p>Only suitable for data sizes that fit in memory. All output |
| syntaxes that do some form of pretty printing will need additional |
| space for their internal datastructures.</p> |
| <pre><code> sdbsql SPEC [ --file=FILE | SQL string ] |
| </code></pre> |
| <p>Execute a SQL command on the store, using the connection details |
| from the store specification. The SQL command either comes from |
| file <code>FILE</code> or the command line as a string.</p> |
| <pre><code> sdbinfo SPEC |
| </code></pre> |
| <p>Details of a store.</p> |
| <pre><code> sdbmeta SPEC --out=SYNTAX |
| </code></pre> |
| <p>Do things with the meta graphs of a store.</p> |
| <pre><code> sdbscript SPEC FILE |
| </code></pre> |
| <p>Execute a script. Currently only JRuby is supported.</p> |
| <pre><code> sdbtuple SPEC [--create|--print|--drop|--truncate] tableName |
| </code></pre> |
| <p>Many of the tables used within SDB are tuples of RDF nodes. This |
| command allows low-level access to these tuple tables. Misuse of |
| this command can corrupt the store.</p> |
| |
| |
| </div> |
| </div> |
| |
| </div> |
| |
| <footer class="footer"> |
| <div class="container" style="font-size:80%" > |
| <p> |
| Copyright © 2011–2022 The Apache Software Foundation, Licensed under the |
| <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>. |
| </p> |
| <p> |
| Apache Jena, Jena, the Apache Jena project logo, Apache and the Apache feather logos are trademarks of |
| The Apache Software Foundation. |
| <br/> |
| <a href="https://privacy.apache.org/policies/privacy-policy-public.html" |
| >Apache Software Foundation Privacy Policy</a>. |
| </p> |
| </div> |
| </footer> |
| |
| |
| <script type="text/javascript"> |
| var link = $('a[href="' + this.location.pathname + '"]'); |
| if (link != undefined) |
| link.parents('li,ul').addClass('active'); |
| </script> |
| |
| </body> |
| </html> |