databaseintro.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!-- meta page description: Database management in GRASS GIS -->
  2. <!-- meta page index: database -->
  3. <h3>Attribute management in general</h3>
  4. GRASS can be linked to one or many database management systems (DBMS).
  5. The <em>db.*</em> set of commands provides basic SQL support for
  6. attribute management, while the <em>v.db.*</em> set of commands operates
  7. on the vector map (see <a href="vectorintro.html">Vector introduction</a>).
  8. <h3>Available drivers</h3>
  9. Available drivers are listed in <a href="sql.html">SQL support in GRASS GIS</a>.
  10. <p>
  11. <b>Notes</b>:<br>
  12. The DBF driver provides only very limited SQL
  13. support (as DBF is not an SQL DB) while the other DBMS backends (such
  14. as SQLite, PostgreSQL, MySQL etc) provide full SQL support since the SQL
  15. commands are sent directly to the DBMS. For this reason, the SQLite driver
  16. is the default DBMI backend.
  17. <h3>DB connection management</h3>
  18. The current database management settings are shown or modified with
  19. <a href="db.connect.html">db.connect</a> for current mapset. Available DBMI drivers
  20. are listed with <a href="db.drivers.html">db.drivers</a>. Some DBMI backends
  21. require a user/password for driver/database to be set with <a href="db.login.html">db.login</a>.
  22. In order to test a driver, run <a href="db.test.html">db.test</a>.
  23. <h3>Attribute data import and export</h3>
  24. Attribute data can be imported with <a href="db.in.ogr.html">db.in.ogr</a> from
  25. various formats and exported with <a href="db.out.ogr.html">db.out.ogr</a>. To internally
  26. copy a a full table or selectively parts of it, use <a href="db.copy.html">db.copy</a>.
  27. <p>
  28. Further conversion tools:
  29. <ul>
  30. <li><a href="http://sourceforge.net/projects/mdbtools">MDB Tools</a>: Convert MS-Access data to SQL, DBF, etc.</li>
  31. <li><a href="https://grasswiki.osgeo.org/wiki/Openoffice.org_with_SQL_Databases">Using OpenOffice.org with SQL Databases</a>
  32. </ul>
  33. <h3>SQL commands</h3>
  34. GRASS supports two main SQL operations, execution of an SQL statement
  35. (<a href="db.execute.html">db.execute</a>) and selection
  36. of data from a table (<a href="db.select.html">db.select</a>).
  37. See the <a href="sql.html">SQL help page</a> for examples.
  38. <h3>Managing the default DBMI settings</h3>
  39. Per default vector map attributes are stored in SQLite tables. This default
  40. definition can be modified with <a href="db.connect.html">db.connect</a>. If an
  41. external DBMS is used, <a href="db.login.html">db.login</a> may be required.
  42. <h3>Creating a database</h3>
  43. Specific commands are explained on the individual driver pages (these
  44. pages are only available if driver was compiled in this installation):
  45. <ul>
  46. <li>DBF: see <a href="grass-dbf.html">DBF</a> page</li>
  47. <li>SQLite: <a href="grass-sqlite.html">SQLite</a> page</li>
  48. <li>mySQL: <a href="grass-mysql.html">mySQL</a> and <a href="grass-mesql.html">meSQL</a> pages</li>
  49. <li>ODBC: <a href="grass-odbc.html">ODBC</a> page (connect to Oracle, etc.)</li>
  50. <li>PostgreSQL: <a href="grass-pg.html">PostgreSQL</a> and PostGIS page</li>
  51. </ul>
  52. <h3>Metadata</h3>
  53. All columns for a given table are listed with <a href="db.columns.html">db.columns</a>.
  54. The command <a href="db.describe.html">db.describe</a> describes a table in detail. To
  55. list all available tables for a given database, run <a href="db.tables.html">db.tables</a>.
  56. <h3>Table maintenance</h3>
  57. To drop a column from a selected attribute table, use <a href="db.dropcolumn.html">db.dropcolumn</a>.
  58. With <a href="db.droptable.html">db.droptable</a> an attribute table can be deleted.
  59. <h3>Database Schema</h3>
  60. Currently schema support only works for PostgreSQL connections. Default schema
  61. can be set with <a href="db.connect.html">db.connect</a>. Note that the default
  62. schema will be used by all db.* modules.
  63. <p>
  64. <a href="db.tables.html">db.tables</a> returns 'schema.table' if schemas are
  65. available in the database.
  66. <h3>Migrating to a different database engine</h3>
  67. To migrate a GRASS database table (or a GRASS vector map) to a different DBMI engine,
  68. the best solution is to create a new MAPSET, define the DBMI settings accordingly
  69. with <a href="db.connect.html">db.connect</a> and if needed, <a href="db.login.html">db.login</a>.
  70. Then the table of interest can be copied over with <a href="db.copy.html">db.copy</a> from
  71. the original MAPSET. Likewise, a vector map including its table(s) are copied from
  72. the original MAPSET to the current MAPSET with <a href="g.copy.html">g.copy</a>.
  73. <h3>See also</h3>
  74. <ul>
  75. <li><a href="rasterintro.html">Introduction into raster data processing</a></li>
  76. <li><a href="raster3dintro.html">Introduction into 3D raster data (voxel) processing</a></li>
  77. <li><a href="vectorintro.html">Introduction into vector data processing</a></li>
  78. <li><a href="imageryintro.html">Introduction into image processing</a></li>
  79. <li><a href="temporalintro.html">Introduction into temporal data processing</a></li>
  80. <li><a href="projectionintro.html">Projections and spatial transformations</a></li>
  81. </ul>