Provided by: grass-doc_6.4.3-3_all bug

NAME

       db.select  - Selects data from attribute table (performs SQL query statement(s)).

KEYWORDS

       database, attribute table, SQL

SYNOPSIS

       db.select
       db.select help
       db.select   [-cdvt]    [table=name]     [database=name]     [driver=name]     [sql=string]
       [input=name]   [fs=character]   [vs=character]   [nv=string]   [output=name]   [--verbose]
       [--quiet]

   Flags:
       -c
           Do not include column names in output

       -d
           Describe query only (don't run it)

       -v
           Vertical output (instead of horizontal)

       -t
           Only test query, do not execute

       --verbose
           Verbose module output

       --quiet
           Quiet module output

   Parameters:
       table=name
           Table name

       database=name
           Database name
           Default: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/

       driver=name
           Driver name
           Options: sqlite,mysql,odbc,pg,dbf,ogr
           Default: dbf

       sql=string
           SQL select statement
           For example: 'select * from rybniky where kapri = 'hodne'

       input=name
           Name of file with sql statement

       fs=character
           Field separator
           Output field separator
           Default: |

       vs=character
           Field separator
           Output vertical record separator

       nv=string
           Null value indicator

       output=name
           Name for output file (if omitted or "-" output to stdout)

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 input=file.sql

       Select all from table roads

       db.select -c driver=odbc database=mydb table=roads \
                 input=file.sql output=result.csv

       Select some string attribute, exclude others:

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

       Select some string attribute with ZERO length:

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

       Select coordinates from PostGIS table:

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

       Count number of cases falling into same position:
       When multiple observation have the spatial coordinates, they  can  still  be  counted  (if
       needed, coordinates can be uploaded to the attribute table by v.to.db:
       db.select sql="SELECT long,lat,site_id,department,obs,COUNT(long) as count_cases \
                      FROM diseases GROUP BY long,lat"

SEE ALSO

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

AUTHOR

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

       Last changed: $Date: 2013-04-09 09:52:11 -0700 (Tue, 09 Apr 2013) $

       Full index

       © 2003-2013 GRASS Development Team