man sql () - SQL support for GRASS.
DESCRIPTION
SQL support for GRASS.
Supported is a limited set of SQL functions and operators.
FUNCTIONS
ALTER TABLE table ADD [COLUMN] columndef
CREATE TABLE table ( columndefs )
DROP TABLE table
SELECT columns FROM table
SELECT columns FROM table WHERE condition
DELETE FROM table
DELETE FROM table WHERE condition
INSERT INTO table values
INSERT INTO table ( columns ) values
UPDATE table SET assignments
UPDATE table SET assignments WHERE condition
OPERATORS
"=" : equal
"<" : smaller than
"<=" : smaller/equal than
">" : larger than
">=" : larger/equal than
"<>" : not equal
"~" : Substring matching
NOTES
- SQL does not support '.' (dots) in table names.
-
Supported table name characters are only:
[A-Za-z][A-Za-z0-9_]*
- A table name must start with a character, not a number.
-
Brackets are needed, e.g. for
select * from some_table where (3*(some_field - another_field) > 5)
The parser does not know about precedence yet, so the sub-clause has to
be in brackets to avoid ambiguity.
-
Text-string matching requires the text part to be 'single quoted' and
multiple queries should be contained in "double quotes". e.g.
d.vect map where="individual='juvenile' and area='beach'"
- An error message such as "dbmi: Protocol error" either indicates an invalid column name or an unsupported column type (then the GRASS SQL parser needs to be extended).
- DBF column names are limited to 10 characters (DBF API definition)
EXAMPLES
Display all vector points except for LAMAR valley and extensive trapping:
d.vect trapping_sites_points fcol=black icon=basic/diamond col=white size=13
where="valley <> 'LAMAR' OR (valley = 'LAMAR' AND description = 'extensive trapping')"
Select all attributes from table where str1 column values are not 'No Name':
echo "SELECT * FROM archsites WHERE str1 <> 'No Name'" | db.select
SEE ALSO
db.execute,
db.select,
db.tables,
d.vect
SQL reference links
Last changed: $Date: 2005/05/10 09:58:07 $
Help Index