123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>GRASS GIS manual: GRASS-DBF driver</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" href="grassdocs.css" type="text/css">
- </head>
- <body bgcolor="white">
- <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
- <!-- meta page description: DBF driver -->
- <h1>DBF driver in GRASS</h1>
- <h2>KEYWORDS</h2>
- database, attribute table, driver
- <h2>DESCRIPTION</h2>
- The DBF driver is a file based attribute table driver.
- <h2>Defining the DBF driver</h2>
- 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:
- <div class="code"><pre>
- # keep single quotes:
- db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
- db.connect -p
- </pre></div>
- The dbf/ subdirectory in the mapset must exist or must be created by the user.
- <h2>Creating a DBF table</h2>
- DBF tables are created by GRASS when generating a vector map
- with attributes and having defined the DBF as attribute driver.
- <p>
- If a DBF table has to be created manually, <a href="db.execute.html">db.execute</a>
- can be used or a spreadsheet application. Also <a href="db.copy.html">db.copy</a>
- is sometimes useful as well as <a href="db.in.ogr.html">db.in.ogr</a> to import external
- tables.
- <h2>Supported SQL commands by DBF driver</h2>
- <div class="code"><pre>
- 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
- </pre></div>
- <h2>Operators available in conditions</h2>
- <div class="code"><pre>
- "=" : equal
- "<" : smaller than
- "<=" : smaller/equal than
- ">" : larger than
- ">=" : larger/equal than
- "<>" : not equal
- "~" : Substring matching (non-standard SQL)
- "%" : Substring matching (limited functionality)
- </pre></div>
- <p>
- 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 '(' and ')') are supported.
- <br>
- Type conversion is performed if necessary (experimental).
- <p>
- Conditions allow boolean expressions using the AND, OR and NOT operators,
- with the usual precedence rules.
- <p>
- NULLs can be tested by 'colname IS NULL' in conditions. The negation is
- 'colname NOT NULL'.
- <p>
- Sorting: Empty fields in a character column are sorted to the end.
- <h2>LIMITATIONS OF THE DBF DRIVER</h2>
- The DBF driver supports only a <b>few SQL statements</b> 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,
- <ul>
- <li> aggregate functions (sum, count, min, max,...) are <b>not</b> supported
- in SELECT clauses;</li>
- <li> mathematic functions (sin, cos, exp, log,...) are <b>not</b> supported
- in expressions;</li>
- <li> SQL query with IN are <b>not</b> supported.</li>
- </ul>
- <h2>ERROR MESSAGES</h2>
- An error message such as:
- <div class="code"><pre>
- DBMI-DBF driver error:
- SQL parser error: syntax error, unexpected NAME processing 'IN'..
- </pre></div>
- indicates that an unsupported SQL statement (here, 'IN') was used. The only
- solution is to switch the DBMI backend to a real SQL engine (SQLite,
- PostgreSQL, MySQL etc.). See <a href="sql.html">SQL support in GRASS GIS</a>.
- <p>
- An error message such as:
- <div class="code"><pre>
- DBMI-DBF driver error:
- SQL parser error: syntax error, unexpected DESC, expecting NAME processing 'DESC'
- </pre></div>
- indicates that a column name corresponds to a reserved SQL word (here: 'DESC').
- A different column name should be used. If this happens during import with
- <em>v.in.ogr</em>, the <em>cnames</em> parameter can be used to assign different
- column names on the fly.
- <h2>SEE ALSO</h2>
- <em>
- <a href="db.connect.html">db.connect</a>,
- <a href="sql.html">SQL support in GRASS GIS</a><br>
- <a href="http://shapelib.maptools.org/dbf_api.html">DBF Specifications</a> (Shapelib)
- </em>
- <p><i>Last changed: $Date$</i>
- <hr>
- <p><a href="index.html">Main index</a> - <a href="database.html">Database index</a> - <a href="topics.html">Topics index</a> - <a href="keywords.html">Keywords Index</a> - <a href="full_index.html">Full index</a></p>
- <p>© 2003-2013 <a href="http://grass.osgeo.org">GRASS Development Team</a>, GRASS GIS 7.0.svn Reference Manual</p>
- </body>
- </html>
|