123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <h2>DESCRIPTION</h2>
- <em>db.select</em> prints result of selection from database based on
- SQL statement read from input file or from standard input to standard
- output.
- <h2>NOTE</h2>
- If parameters for database connection are already set with
- <em><a href="db.connect.html">db.connect</a></em>, they are taken as
- default values and do not need to be specified each time. Output will
- be displayed to standard output or can be directed to a file
- (option <b>output</b>).
- <h2>EXAMPLES</h2>
- Basic usage:
- <div class="code"><pre>
- db.select sql="select * from roads"
- </pre></div>
- or
- <div class="code"><pre>
- echo "select * from roads" | db.select input=-
- </pre></div>
- or
- <div class="code"><pre>
- db.select input=file.sql
- </pre></div>
- or
- <div class="code"><pre>
- cat file.sql | db.select input=-
- </pre></div>
- <p>
- Select all from table roads:
- <div class="code"><pre>
- db.select -c driver=odbc database=mydb table=roads \
- input=file.sql output=result.csv
- </pre></div>
- <p>
- Select some string attribute, exclude others:
- <div class="code"><pre>
- db.select sql="SELECT * FROM archsites WHERE str1 <> 'No Name'"
- </pre></div>
- <p>
- Select some string attribute with ZERO length:
- <div class="code"><pre>
- db.select sql="SELECT * FROM archsites WHERE str1 IS NULL"
- </pre></div>
- <p>
- Select coordinates from PostGIS table:
- <div class="code"><pre>
- db.select sql="SELECT x(geo),y(geo) FROM localizzazione"
- </pre></div>
- <p>Execute multiple SQL statements:
- <div class="code"><pre>
- cat file.sql
- SELECT * FROM busstopsall WHERE cat = 1
- SELECT cat FROM busstopsall WHERE cat > 4 AND cat < 8
- db.select input=file.sql
- </pre></div>
- <p>
- <em>Count number of cases falling into same position:</em><br>
- When multiple observation have the spatial coordinates, they can still be counted
- (if needed, coordinates can be uploaded to the attribute table by <em>v.to.db</em>:
- <div class="code"><pre>
- db.select sql="SELECT long,lat,site_id,department,obs,COUNT(long) as count_cases \
- FROM diseases GROUP BY long,lat"
- </pre></div>
- <h2>SEE ALSO</h2>
- <em>
- <a href="sql.html">GRASS SQL interface</a>
- </em>
- <p>
- <em>
- <a href="db.connect.html">db.connect</a>,
- <a href="db.describe.html">db.describe</a>,
- <a href="db.drivers.html">db.drivers</a>,
- <a href="db.droptable.html">db.droptable</a>,
- <a href="db.execute.html">db.execute</a>,
- <a href="db.login.html">db.login</a>,
- <a href="db.tables.html">db.tables</a>
- </em>
- <h2>AUTHOR</h2>
- Original author unknown (probably CERL)<br>
- Modifications by Radim Blazek, ITC-Irst, Trento, Italy<br>
- Support for multiple statements by Martin Landa, Czech Technical University in Prague
- <p>
- <i>Last changed: $Date$</i>
|