<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>8.3.15. load — groonga v3.0.5 documentation</title> <link rel="stylesheet" href="../../_static/groonga.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '3.0.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <link rel="shortcut icon" href="../../_static/favicon.ico"/> <link rel="top" title="groonga v3.0.5 documentation" href="../../index.html" /> <link rel="up" title="8.3. Command" href="../command.html" /> <link rel="next" title="8.3.16. log_level" href="log_level.html" /> <link rel="prev" title="8.3.14. dump" href="dump.html" /> </head> <body> <div class="header"> <h1 class="title"> <a id="top-link" href="../../index.html"> <span class="project">groonga</span> <span class="separator">-</span> <span class="description">An open-source fulltext search engine and column store.</span> </a> </h1> <div class="other-language-links"> <ul> <li><a href="../../../../ja/html/reference/commands/load.html"><img src="../../_static/jp.png" alt="日本語">日本語版はこちら</a></li> </ul> </div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="log_level.html" title="8.3.16. log_level" accesskey="N">next</a> |</li> <li class="right" > <a href="dump.html" title="8.3.14. dump" accesskey="P">previous</a> |</li> <li><a href="../../index.html">groonga v3.0.5 documentation</a> »</li> <li><a href="../../reference.html" >8. リファレンスマニュアル</a> »</li> <li><a href="../command.html" accesskey="U">8.3. Command</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="load"> <h1>8.3.15. <tt class="docutils literal"><span class="pre">load</span></tt><a class="headerlink" href="#load" title="Permalink to this headline">¶</a></h1> <div class="section" id="summary"> <h2>8.3.15.1. Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2> <p><tt class="docutils literal"><span class="pre">load</span></tt> loads data as records in the current database and updates values of each columns.</p> </div> <div class="section" id="syntax"> <h2>8.3.15.2. Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2> <div class="highlight-none"><div class="highlight"><pre>load values table [columns [ifexists [input_type]]] </pre></div> </div> </div> <div class="section" id="parameters"> <h2>8.3.15.3. Parameters<a class="headerlink" href="#parameters" title="Permalink to this headline">¶</a></h2> <p>This section describes all parameters.</p> <p><tt class="docutils literal"><span class="pre">values</span></tt></p> <blockquote> <div><p>It specifies values loaded to records. Values should satisfy <tt class="docutils literal"><span class="pre">input_type</span></tt> format. If you specify "json" as <tt class="docutils literal"><span class="pre">input_type</span></tt>, you can choose a format from below:</p> <dl class="docutils"> <dt><tt class="docutils literal"><span class="pre">Format</span> <span class="pre">1:</span></tt></dt> <dd>[[COLUMN_NAME1, COLUMN_NAME2,..], [VALUE1, VALUE2,..], [VALUE1, VALUE2,..],..]</dd> <dt><tt class="docutils literal"><span class="pre">Format</span> <span class="pre">2:</span></tt></dt> <dd>[{COLUMN_NAME1: VALUE1, COLUMN_NAME2: VALUE2}, {COLUMN_NAME1: VALUE1, COLUMN_NAME2: VALUE2},..]</dd> </dl> <p><tt class="docutils literal"><span class="pre">[COLUMN_NAME1,</span> <span class="pre">COLUMN_NAME2,..]</span></tt> format in <tt class="docutils literal"><span class="pre">Format</span> <span class="pre">1</span></tt> is effective only when <tt class="docutils literal"><span class="pre">column</span></tt> parameter isn't specified.</p> <p>When a target table contains primary key, you must specify <tt class="docutils literal"><span class="pre">_key</span></tt> column (pseudo column associated primary key) as the one of <tt class="docutils literal"><span class="pre">COLUMN_NAME</span></tt>.</p> <p>If <tt class="docutils literal"><span class="pre">values</span></tt> isn't specified any values, they are read from the standard input until all opened parenthes match their closed ones. You don't have to enclose them with single-quotes or double-quotes, but if you specified values with <tt class="docutils literal"><span class="pre">values</span></tt> parameter, you should do.</p> <p>In following values, you also don't have to enclose any spaces (' ') with single-quotes or double-quotes.</p> </div></blockquote> <p><tt class="docutils literal"><span class="pre">table</span></tt></p> <blockquote> <div>It specifies a table name you want to add records.</div></blockquote> <p><tt class="docutils literal"><span class="pre">columns</span></tt></p> <blockquote> <div>It specifies column names in added records with comma separations.</div></blockquote> <p><tt class="docutils literal"><span class="pre">ifexists</span></tt></p> <blockquote> <div>It specifies executed <tt class="docutils literal"><span class="pre">grn_expr</span></tt> string when the same primary key as added records already exists in your table. If <tt class="docutils literal"><span class="pre">ifexists</span></tt> specifies <tt class="docutils literal"><span class="pre">grn_expr</span></tt> string (default: true) and its value is true, values in other (all columns excluding <tt class="docutils literal"><span class="pre">_key</span></tt> column) columns is updated.</div></blockquote> <p><tt class="docutils literal"><span class="pre">input_type</span></tt></p> <blockquote> <div>It specifies an input format for <tt class="docutils literal"><span class="pre">values</span></tt>. It supports JSON only.</div></blockquote> </div> <div class="section" id="usage"> <h2>8.3.15.4. Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2> <p>Here is an example to add records to "Entry" table.</p> <div class="highlight-none"><div class="highlight"><pre>load --table Entry --input_type json --values [{\"_key\":\"Groonga\",\"body\":\"It's very fast!!\"}] [1] </pre></div> </div> <p>This example shows how to add values from standard input.</p> <div class="highlight-none"><div class="highlight"><pre>load --table Entry --input_type json [ {"_key": "Groonga", "body": "It's very fast!!"} ] [1] </pre></div> </div> </div> <div class="section" id="return-value"> <h2>8.3.15.5. Return value<a class="headerlink" href="#return-value" title="Permalink to this headline">¶</a></h2> <div class="section" id="json-format"> <h3>8.3.15.5.1. JSON format<a class="headerlink" href="#json-format" title="Permalink to this headline">¶</a></h3> <blockquote> <div><p><tt class="docutils literal"><span class="pre">load</span></tt> returns the number of added records such as</p> <div class="highlight-none"><div class="highlight"><pre>[NUMBER] </pre></div> </div> </div></blockquote> </div> </div> <div class="section" id="see-also"> <h2>8.3.15.6. See also<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2> <p><a class="reference internal" href="../grn_expr.html"><em>grn_expr</em></a></p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">8.3.15. <tt class="docutils literal"><span class="pre">load</span></tt></a><ul> <li><a class="reference internal" href="#summary">8.3.15.1. Summary</a></li> <li><a class="reference internal" href="#syntax">8.3.15.2. Syntax</a></li> <li><a class="reference internal" href="#parameters">8.3.15.3. Parameters</a></li> <li><a class="reference internal" href="#usage">8.3.15.4. Usage</a></li> <li><a class="reference internal" href="#return-value">8.3.15.5. Return value</a><ul> <li><a class="reference internal" href="#json-format">8.3.15.5.1. JSON format</a></li> </ul> </li> <li><a class="reference internal" href="#see-also">8.3.15.6. See also</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="dump.html" title="previous chapter">8.3.14. dump</a></p> <h4>Next topic</h4> <p class="topless"><a href="log_level.html" title="next chapter">8.3.16. log_level</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/reference/commands/load.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="log_level.html" title="8.3.16. log_level" >next</a> |</li> <li class="right" > <a href="dump.html" title="8.3.14. dump" >previous</a> |</li> <li><a href="../../index.html">groonga v3.0.5 documentation</a> »</li> <li><a href="../../reference.html" >8. リファレンスマニュアル</a> »</li> <li><a href="../command.html" >8.3. Command</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2013, Brazil, Inc. </div> </body> </html>