grass-dbf.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>GRASS GIS manual: GRASS-DBF driver</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  7. </head>
  8. <body bgcolor="white">
  9. <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
  10. <!-- meta page description: DBF driver -->
  11. <h1>DBF driver in GRASS</h1>
  12. <h2>KEYWORDS</h2>
  13. database, attribute table, driver
  14. <h2>DESCRIPTION</h2>
  15. The DBF driver is a file based attribute table driver.
  16. <h2>Defining the DBF driver</h2>
  17. The DBF driver is a file based driver, in theory no user interaction is
  18. required. However, if the settings should be set back from a different
  19. driver to the DBF driver, the following step is required:
  20. <div class="code"><pre>
  21. # keep single quotes:
  22. db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
  23. db.connect -p
  24. </pre></div>
  25. The dbf/ subdirectory in the mapset must exist or must be created by the user.
  26. <h2>Creating a DBF table</h2>
  27. DBF tables are created by GRASS when generating a vector map
  28. with attributes and having defined the DBF as attribute driver.
  29. <p>
  30. If a DBF table has to be created manually, <a href="db.execute.html">db.execute</a>
  31. can be used or a spreadsheet application. Also <a href="db.copy.html">db.copy</a>
  32. is sometimes useful as well as <a href="db.in.ogr.html">db.in.ogr</a> to import external
  33. tables.
  34. <h2>Supported SQL commands by DBF driver</h2>
  35. <div class="code"><pre>
  36. ALTER TABLE table ADD [COLUMN] columndef
  37. ALTER TABLE table DROP COLUMN colname
  38. CREATE TABLE table ( columndefs )
  39. DROP TABLE table
  40. SELECT columns FROM table
  41. SELECT columns FROM table WHERE condition
  42. SELECT columns FROM table ORDER BY column
  43. DELETE FROM table
  44. DELETE FROM table WHERE condition
  45. INSERT INTO table VALUES (value1[,value2,...])
  46. INSERT INTO table ( column1[,column2,...] ) VALUES (value1[,value2,...])
  47. UPDATE table SET assignment1[,assignment2,...]
  48. UPDATE table SET assignment1[,assignment2,...] WHERE condition
  49. </pre></div>
  50. <h2>Operators available in conditions</h2>
  51. <div class="code"><pre>
  52. "=" : equal
  53. "&lt;" : smaller than
  54. "&lt;=" : smaller/equal than
  55. "&gt;" : larger than
  56. "&gt;=" : larger/equal than
  57. "&lt;&gt;" : not equal
  58. "~" : Substring matching (non-standard SQL)
  59. "%" : Substring matching (limited functionality)
  60. </pre></div>
  61. <p>
  62. Arithmetic expressions using constants and field values are allowed
  63. in condition clauses and in the RHS of assignments.
  64. <br>
  65. Usual precedence rules and bracketing (using '(' and ')') are supported.
  66. <br>
  67. Type conversion is performed if necessary (experimental).
  68. <p>
  69. Conditions allow boolean expressions using the AND, OR and NOT operators,
  70. with the usual precedence rules.
  71. <p>
  72. NULLs can be tested by 'colname IS NULL' in conditions. The negation is
  73. 'colname NOT NULL'.
  74. <p>
  75. Sorting: Empty fields in a character column are sorted to the end.
  76. <h2>LIMITATIONS OF THE DBF DRIVER</h2>
  77. The DBF driver supports only a <b>few SQL statements</b> since the DBF tables are
  78. intended for simple table storage. DBF column names are limited to 10 characters
  79. (as defined in the DBF specifications). For example,
  80. <ul>
  81. <li> aggregate functions (sum, count, min, max,...) are <b>not</b> supported
  82. in SELECT clauses;</li>
  83. <li> mathematic functions (sin, cos, exp, log,...) are <b>not</b> supported
  84. in expressions;</li>
  85. <li> SQL query with IN are <b>not</b> supported.</li>
  86. </ul>
  87. <h2>ERROR MESSAGES</h2>
  88. An error message such as:
  89. <div class="code"><pre>
  90. DBMI-DBF driver error:
  91. SQL parser error: syntax error, unexpected NAME processing 'IN'..
  92. </pre></div>
  93. indicates that an unsupported SQL statement (here, 'IN') was used. The only
  94. solution is to switch the DBMI backend to a real SQL engine (SQLite,
  95. PostgreSQL, MySQL etc.). See <a href="sql.html">SQL support in GRASS GIS</a>.
  96. <p>
  97. An error message such as:
  98. <div class="code"><pre>
  99. DBMI-DBF driver error:
  100. SQL parser error: syntax error, unexpected DESC, expecting NAME processing 'DESC'
  101. </pre></div>
  102. indicates that a column name corresponds to a reserved SQL word (here: 'DESC').
  103. A different column name should be used. If this happens during import with
  104. <em>v.in.ogr</em>, the <em>cnames</em> parameter can be used to assign different
  105. column names on the fly.
  106. <h2>SEE ALSO</h2>
  107. <em>
  108. <a href="db.connect.html">db.connect</a>,
  109. <a href="sql.html">SQL support in GRASS GIS</a><br>
  110. <a href="http://shapelib.maptools.org/dbf_api.html">DBF Specifications</a> (Shapelib)
  111. </em>
  112. <p><i>Last changed: $Date$</i>
  113. <hr>
  114. <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>
  115. <p>&copy; 2003-2013 <a href="http://grass.osgeo.org">GRASS Development Team</a>, GRASS GIS 7.0.svn Reference Manual</p>
  116. </body>
  117. </html>