databaseintro(1grass)
π databaseintro(1grass) β Database management in GRASS π
okay bestie, sit down, grab a strawberry π because this is your whole crash course on how GRASS handles databases. it's giving "group project but make it SQL". let's gooo β¨
ποΈ Attribute management in general
GRASS can be linked to one or many database management systems (DBMS) β like, it's not monogamous, it plays the field. π
- the
db.*set of commands gives you basic SQL support for attribute management - the
v.db.*set of commands operates on the vector map (peep the Vector introduction for that lore π¦)
π Available drivers
Available drivers are listed in SQL support in GRASS.
Notes, bestie, listen up π
The DBF driver provides only very limited SQL support (as DBF is not an SQL DB) β it's giving "trying its best" π. 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. π
π DB connection management
The current database management settings are shown or modified with db.connect for the 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.ogrfrom various formats π«Ά - ...and exported with
db.out.ogrπ - To internally copy a full table or selectively parts of it, use
db.copy.
Further conversion tools:
- MDB Tools: Convert MS-Access data to SQL, DBF, etc. πβ‘οΈβ¨
- Using OpenOffice.org with SQL Databases
π» SQL commands
GRASS supports two main SQL operations:
- execution of an SQL statement β that's
db.executeπ₯ - selection of data from a table β that's
db.selectπ
See the SQL help page for examples. iykyk π
βοΈ 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. π
ποΈ Creating a database
Specific commands are explained on the individual driver pages (heads up: these pages are only available if the driver was compiled in this installation π):
- DBF: see DBF page
- SQLite: SQLite page
- mySQL: mySQL and 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.describedescribes a table in detail. - To list all available tables for a given database, run
db.tables.
literally your table's whole vibe check πͺ
π§Ή Table maintenance
- To drop a column from a selected attribute table, use
db.dropcolumn. - With
db.droptablean attribute table can be deleted.
bye bye column, bye bye table πβοΈ
𧬠Database Schema
Currently schema support only works for PostgreSQL connections. no cap.
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.
π 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:
- create a new
MAPSETπ - define the DBMI settings accordingly with
db.connectand if needed,db.login - then the table of interest can be copied over with
db.copyfrom the originalMAPSET
Likewise, a vector map including its table(s) are copied from the original MAPSET to the current MAPSET with g.copy. π¦
π See also
- Introduction into raster data processing
- Introduction into 3D raster data (voxel) processing
- Introduction into vector data processing
- Introduction into image processing
- Introduction into temporal data processing
- Projections and spatial transformations
π SOURCE CODE
Available at: Database management in GRASS source code (history)
Accessed: Friday May 08 10:38:23 2026
Main index | Database index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual
and that's the whole page, bestie π«Ά this is GRASS 8.5.0, databaseintro(1grass), periodt. π
β¨π
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms