databaseintro.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Database management in GRASS GIS</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta name="Author" content="Markus Neteler/GRASS Development Team">
  7. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  8. </head>
  9. <body bgcolor="white">
  10. <!-- This page is grass6/db/databaseintro.html -->
  11. <img src="grass_logo.png" alt="_\|/_ GRASS logo"><hr align=center size=6 noshade>
  12. <!-- meta page description: Database management in GRASS GIS -->
  13. <h2>Database management in GRASS GIS</h2>
  14. <h3>Attribute management in general</h3>
  15. GRASS can be linked to one or many database management systems (DBMS).
  16. The <em>db.*</em> set of commands provides basic SQL support for
  17. attribute management, while the <em>v.db.*</em> set of commands operates
  18. on the vector map (see <a href="vectorintro.html">Vector introduction</a>).
  19. <h3>Available drivers</h3>
  20. Available drivers are listed in <a href="sql.html">SQL support in GRASS GIS</a>.
  21. <p>
  22. <b>Notes</b>:<br>
  23. The DBF driver provides only very limited SQL
  24. support (as DBF is not an SQL DB) while the other DBMS backends (such
  25. as SQLite, PostgreSQL, MySQL etc) provide full SQL support since the SQL
  26. commands are sent directly to the DBMS. For this reason, the SQLite driver
  27. is the default DBMI backend.
  28. <h3>DB connection management</h3>
  29. The current database management settings are shown or modified with
  30. <a href="db.connect.html">db.connect</a> for current mapset. Available DBMI drivers
  31. are listed with <a href="db.drivers.html">db.drivers</a>. Some DBMI backends
  32. require a user/password for driver/database to be set with <a href="db.login.html">db.login</a>.
  33. In order to test a driver, run <a href="db.test.html">db.test</a>.
  34. <h3>Attribute data import and export</h3>
  35. Attribute data can be imported with <a href="db.in.ogr.html">db.in.ogr</a> from
  36. various formats and exported with <a href="db.out.ogr.html">db.out.ogr</a>. To internally
  37. copy a a full table or selectively parts of it, use <a href="db.copy.html">db.copy</a>.
  38. <p>
  39. Further conversion tools:
  40. <ul>
  41. <li><a href="http://sourceforge.net/projects/mdbtools">MDB Tools</a>: Convert MS-Access data to SQL, DBF, etc.</li>
  42. <li><a href="http://grass.osgeo.org/wiki/Openoffice.org_with_SQL_Databases">Using OpenOffice.org with SQL Databases</a>
  43. </ul>
  44. <h3>SQL commands</h3>
  45. GRASS supports to main SQL operations, execution of an SQL statement
  46. (<a href="db.execute.html">db.execute</a>) and selection
  47. of data from a table (<a href="db.select.html">db.select</a>).
  48. See the <a href="sql.html">SQL help page</a> for examples.
  49. <h3>Managing the default DBMI settings</h3>
  50. Per default vector map attributes are stored in SQLite tables. This default
  51. definition can be modified with <a href="db.connect.html">db.connect</a>. If an
  52. external DBMS is used, <a href="db.login.html">db.login</a> may be required.
  53. <h3>Creating a database</h3>
  54. Specific commands are explained on the individual driver pages (these
  55. pages are only available if driver was compiled in this installation):
  56. <ul>
  57. <li>DBF: see <a href="grass-dbf.html">DBF</a> page</li>
  58. <li>SQLite: <a href="grass-sqlite.html">SQLite</a> page</li>
  59. <li>mySQL: <a href="grass-mysql.html">mySQL</a> and <a href="grass-mesql.html">meSQL</a> pages</li>
  60. <li>ODBC: <a href="grass-odbc.html">ODBC</a> page (connect to Oracle, etc.)</li>
  61. <li>PostgreSQL: <a href="grass-pg.html">PostgreSQL</a> and PostGIS page</li>
  62. </ul>
  63. <h3>Metadata</h3>
  64. All columns for a given table are listed with <a href="db.columns.html">db.columns</a>.
  65. The command <a href="db.describe.html">db.describe</a> describes a table in detail. To
  66. list all available tables for a given database, run <a href="db.tables.html">db.tables</a>.
  67. <h3>Table maintenance</h3>
  68. To drop a column from a selected attribute table, use <a href="db.dropcol.html">db.dropcol</a>.
  69. With <a href="db.droptable.html">db.droptable</a> an attribute table can be deleted.
  70. <h3>Database Schema</h3>
  71. Currently schema support only works for PostgreSQL connections. Default schema
  72. can be set with <a href="db.connect.html">db.connect</a>. Note that the default
  73. schema will be used by all db.* modules.
  74. <p>
  75. <a href="db.tables.html">db.tables</a> returns 'schema.table' if schemas are
  76. available in the database.
  77. <h3>Migrating to a different database engine</h3>
  78. To migrate a GRASS database table (or a GRASS vector map) to a different DBMI engine,
  79. the best solution is to create a new MAPSET, define the DBMI settings accordingly
  80. with <a href="db.connect.html">db.connect</a> and if needed, <a href="db.login.html">db.login</a>.
  81. Then the table of interest can be copied over with <a href="db.copy.html">db.copy</a> from
  82. the original MAPSET. Likewise, a vector map including its table(s) are copied from
  83. the original MAPSET to the current MAPSET with <a href="g.copy.html">g.copy</a>.
  84. <h3>See also</h3>
  85. <ul>
  86. <li><a href="vectorintro.html">Introduction to GRASS vector map processing</a></li>
  87. <li><a href="rasterintro.html">Introduction to GRASS raster map processing</a></li>
  88. </ul>
  89. <HR>
  90. <BR>
  91. <a href="index.html">Main index</a> -
  92. <a href="database.html">database index</a> -
  93. <a href="full_index.html">full index</a>
  94. <p><i>Last changed: $Date$</i></p>
  95. <P>&copy; 2008 <a href="http://grass.osgeo.org">GRASS Development Team</a></P>
  96. </body>
  97. </html>