.TH databaseintro 1grass "" "GRASS 7.8.5" "GRASS GIS User's Manual" .SH Database management in GRASS GIS .SS Attribute management in general GRASS can be linked to one or many database management systems (DBMS). The \fIdb.*\fR set of commands provides basic SQL support for attribute management, while the \fIv.db.*\fR set of commands operates on the vector map (see Vector introduction). .SS Available drivers Available drivers are listed in SQL support in GRASS GIS. .PP \fBNotes\fR: .br The DBF driver provides only very limited SQL support (as DBF is not an SQL DB) while the other DBMS backends (such as SQLite, PostgreSQL, MySQL etc) provide full SQL support since the SQL commands are sent directly to the DBMS. For this reason, the SQLite driver is the default DBMI backend. .SS 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. .SS 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. .PP Further conversion tools: .RS 4n .IP \(bu 4n MDB Tools: Convert MS\-Access data to SQL, DBF, etc. .IP \(bu 4n Using OpenOffice.org with SQL Databases .RE .SS SQL commands GRASS supports two 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. .SS Managing the default DBMI settings Per default vector map attributes are stored in SQLite tables. This default definition can be modified with db.connect. If an external DBMS is used, db.login may be required. .SS Creating a database Specific commands are explained on the individual driver pages (these pages are only available if driver was compiled in this installation): .RS 4n .IP \(bu 4n DBF: see DBF page .IP \(bu 4n SQLite: SQLite page .IP \(bu 4n mySQL: mySQL and meSQL pages .IP \(bu 4n ODBC: ODBC page (connect to Oracle, etc.) .IP \(bu 4n PostgreSQL: PostgreSQL and PostGIS page .RE .SS 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. .SS Table maintenance To drop a column from a selected attribute table, use db.dropcolumn. With db.droptable an attribute table can be deleted. .SS 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. .PP db.tables returns \(cqschema.table\(cq if schemas are available in the database. .SS Migrating to a different database engine To migrate a GRASS database table (or a GRASS vector map) to a different DBMI engine, the best solution is to create a new MAPSET, define the DBMI settings accordingly with db.connect and if needed, db.login. Then the table of interest can be copied over with db.copy from the original MAPSET. Likewise, a vector map including its table(s) are copied from the original MAPSET to the current MAPSET with g.copy. .SS See also .RS 4n .IP \(bu 4n Introduction into raster data processing .IP \(bu 4n Introduction into 3D raster data (voxel) processing .IP \(bu 4n Introduction into vector data processing .IP \(bu 4n Introduction into image processing .IP \(bu 4n Introduction into temporal data processing .IP \(bu 4n Projections and spatial transformations .RE .SH SOURCE CODE .PP Available at: Database management in GRASS GIS source code (history) .PP Main index | Database index | Topics index | Keywords index | Graphical index | Full index .PP © 2003\-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual