man db.select () - Select data from database.

NAME

db.select - Select data from database.

SYNOPSIS

db.select

db.select help

db.select [-cdv] [table=string] [database=string] [driver=string] [sql=string] [fs=string] [vs=string] [nv=string] [input=filename]

Flags:

"-c
do not include column names in output
"-d
describe query only (don't run it)
"-v
vertical output (instead of horizontal)

Parameters:

"table=string
Table name, select all from this table
"database=string
database name
"driver=string
driver name Options: dbf,odbc,pg,mysql,ogr
"sql=string
SQL select statement, for example: 'select * from rybniky where kapri = 'hodne'
"fs=string
output field separator Default: |
"vs=string
output vertical record separator
"nv=string
null value indicator
"input=filename
filename with sql statement

DESCRIPTION

db.select prints result of selection from database based on SQL statement read from input file or from standard input to standard output.

NOTE

If parameters for database connection are already set with db.connect, they are taken as default values and do not need to be spcified each time. Output will be displayed to stdout or can be directed to a file.

EXAMPLES

echo "select * from roads" | db.select



or cat file.sql | db.select



or db.select sql=file.sql

Example: Select all from table roads

db.select -c driver=odbc database=g51test table=roads sql=file.sql > result.csv

Example: Select some string attribute, exclude others:

echo "SELECT * FROM archsites WHERE str1 'No Name'" | db.select

Example: Select some string attribute with ZERO length:

echo "SELECT * FROM archsites WHERE str1 IS NULL" | db.select

Example: Select coordinates from PostGIS table:

echo "SELECT x(geo),y(geo) FROM localizzazione" | db.select

SEE ALSO

GRASS SQL interface, db.connect, db.describe, db.drivers, db.droptable, db.execute, db.login, db.tables

AUTHOR

?

Modifications: Radim Blazek, ITC-Irst, Trento, Italy

Last changed: $Date: 2005/05/10 08:34:23 $

Help Index