databaseintro (1) - Linux Manuals
Database management in GRASS GIS
Attribute management in general
GRASS can be linked to one or many database management systems (DBMS). The db.* set of commands provides basic SQL support for attribute management, while the v.db.* set of commands operates on the vector map (see Vector introduction).Available drivers
Available drivers are listed in SQL support in GRASS GIS.
Notes:
The default DBF driver provides only very limited SQL
support (as DBF is not an SQL DB) while the other DBMS backends (such
as PostgreSQL, MySQL etc) provide full SQL support since the SQL
commands are sent directly to the DBMS.
DB connection management
The current database management settings are shown or modified with db.connect for current mapset. Available DBMI drivers are listed with db.drivers. Some DBMI backends require a user/password for driver/database to be set with db.login. In order to test a driver, run db.test.Attribute data import and export
Attribute data can be imported with db.in.ogr from various formats and exported with db.out.ogr. To internally copy a a full table or selectively parts of it, use db.copy.Further conversion tools:
-
- MDB Tools: Convert MS-Access data to SQL, DBF, etc.
- Openoffice.org with SQL Databases
SQL commands
GRASS supports to main SQL operations, execution of an SQL statement (db.execute) and selection of data from a table (db.select). See the SQL help page for examples.Managing the default DBMI settings
Per default vector map attributes are stored in DBF table files. This default definition can be modified with db.connect. If an external DBMS is used, db.login may be required.Creating a database
Specific commands are explained on the individual driver pages (these pages are only available if driver was compiled in this installation):-
- DBF: see DBF page
- SQLite: SQLite page
- mySQL: meSQL pages
- ODBC: ODBC page (connect to Oracle, etc.)
- PostgreSQL: PostgreSQL and PostGIS page
Metadata
All columns for a given table are listed with db.columns. The command db.describe describes a table in detail. To list all available tables for a given database, run db.tables.Table maintenance
To drop a column from a selected attribute table, use db.dropcol. With db.droptable an attribute table can be deleted.Database Schema
Currently schema support only works for PostgreSQL connections. Default schema can be set with db.connect. Note that the default schema will be used by all db.* modules.db.tables returns 'schema.table' if schemas are available in the database.
See also
-
- Introduction to GRASS vector map processing
- Introduction to GRASS raster map processing
Main index - database index - full index
Last changed: $Date: 2008-02-10 18:09:01 +0100 (Sun, 10 Feb 2008) $