databaseintro.html 5.2 KB

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