grass-dbf.1 3.88 KB
Newer Older
xuebingbing's avatar
xuebingbing committed
1
.TH grass-dbf 1 "" "GRASS 7.8.4" "GRASS GIS User's Manual"
xuebingbing's avatar
xuebingbing committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
.SH DBF DATABASE DRIVER
The DBF driver is a file based attribute table driver.
.SH Defining the DBF driver
The DBF driver is a file based driver, in theory no user interaction is
required. However, if the settings should be set back from a different
driver to the DBF driver, the following step is required:
.br
.nf
\fC
# keep single quotes:
db.connect driver=dbf database=\(cq$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/\(cq
db.connect \-p
\fR
.fi
The dbf/ subdirectory in the mapset must exist or must be created by the user.
.SH Creating a DBF table
DBF tables are created by GRASS when generating a vector map
with attributes and having defined the DBF as attribute driver.
.PP
If a DBF table has to be created manually, db.execute
can be used or a spreadsheet application. Also db.copy
is sometimes useful as well as db.in.ogr to import external
tables.
.SH Supported SQL commands by DBF driver
.br
.nf
\fC
  ALTER TABLE table ADD [COLUMN] columndef
  ALTER TABLE table DROP COLUMN colname
  CREATE TABLE table ( columndefs )
  DROP TABLE table
  SELECT columns FROM table
  SELECT columns FROM table WHERE condition
  SELECT columns FROM table ORDER BY column
  DELETE FROM table
  DELETE FROM table WHERE condition
  INSERT INTO table VALUES (value1[,value2,...])
  INSERT INTO table ( column1[,column2,...] ) VALUES (value1[,value2,...])
  UPDATE table SET assignment1[,assignment2,...]
  UPDATE table SET assignment1[,assignment2,...] WHERE condition
\fR
.fi
.SH Operators available in conditions
.br
.nf
\fC
  \(dq=\(dq  : equal
  \(dq<\(dq  : smaller than
  \(dq<=\(dq : smaller/equal than
  \(dq>\(dq  : larger than
  \(dq>=\(dq : larger/equal than
  \(dq<>\(dq : not equal
  \(dq~\(dq  : Substring matching  (non\-standard SQL)
  \(dq%\(dq  : Substring matching  (limited functionality)
\fR
.fi
.PP
Arithmetic expressions using constants and field values are allowed
in condition clauses and in the RHS of assignments.
.br
Usual precedence rules and bracketing (using \(cq(\(cq and \(cq)\(cq) are supported.
.br
Type conversion is performed if necessary (experimental).
.PP
Conditions allow boolean expressions using the AND, OR and NOT operators,
with the usual precedence rules.
.PP
NULLs can be tested by \(cqcolname IS NULL\(cq in conditions. The negation is
\(cqcolname NOT NULL\(cq.
.PP
Sorting: Empty fields in a character column are sorted to the end.
.SH LIMITATIONS OF THE DBF DRIVER
The DBF driver supports only a \fBfew SQL statements\fR since the DBF tables are
intended for simple table storage. DBF column names are limited to 10 characters
(as defined in the DBF specifications). For example,
.RS 4n
.IP \(bu 4n
aggregate functions (sum, count, min, max,...) are \fBnot\fR supported
in SELECT clauses;
.IP \(bu 4n
mathematic functions (sin, cos, exp, log,...) are \fBnot\fR supported
in expressions;
.IP \(bu 4n
SQL query with IN are \fBnot\fR supported.
.RE
.SH ERROR MESSAGES
An error message such as:
.br
.nf
\fC
DBMI\-DBF driver error:
SQL parser error: syntax error, unexpected NAME processing \(cqIN\(cq..
\fR
.fi
indicates that an unsupported SQL statement (here, \(cqIN\(cq) was used. The only
solution is to switch the DBMI backend to a real SQL engine (SQLite,
PostgreSQL, MySQL etc.). See SQL support in GRASS GIS.
.PP
An error message such as:
.br
.nf
\fC
DBMI\-DBF driver error:
SQL parser error: syntax error, unexpected DESC, expecting NAME processing \(cqDESC\(cq
\fR
.fi
indicates that a column name corresponds to a reserved SQL word (here: \(cqDESC\(cq).
A different column name should be used. If this happens during import with
\fIv.in.ogr\fR, the \fIcnames\fR parameter can be used to assign different
column names on the fly.
.SH SEE ALSO
\fI
db.connect,
SQL support in GRASS GIS
.br
DBF Specifications (Shapelib)
\fR
.PP
Main index |
Topics index |
Keywords index |
Graphical index |
Full index
.PP
xuebingbing's avatar
xuebingbing committed
126
© 2003\-2020
xuebingbing's avatar
xuebingbing committed
127
GRASS Development Team,
xuebingbing's avatar
xuebingbing committed
128
GRASS GIS 7.8.4 Reference Manual