grass-dbf(1)

πŸ’– DBF DATABASE DRIVER πŸ’–

okay so first things first bestie, this is grass-dbf(1) β€” a page from the GRASS GIS User's Manual ✨ and it's all about the DBF driver, which is a file based attribute table driver. that's the whole vibe. let's get into it 🫢


🌸 Defining the DBF driver 🌸

so the DBF driver is a file based driver, which means in theory you don't have to do anything β€” no user interaction required, she just works πŸ’…

BUT. if your settings are currently pointed at a different driver and you need to bring them back to DBF, you gotta do this one little step:

# keep single quotes:
db.connect driver=dbf database=’$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/’
db.connect -p
⚠️ and listen β€” that dbf/ subdirectory inside the mapset must already exist or must be created by the user. it will not manifest itself out of thin air, no cap.

πŸŽ€ Creating a DBF table πŸŽ€

when does a DBF table even get born? GRASS makes them when you generate a vector map that has attributes, as long as you've defined DBF as your attribute driver. iconic behavior honestly ✨

and if you need to create a DBF table manually? you've got options bestie:

  • db.execute β€” the classic
  • a spreadsheet application β€” yes, for real
  • db.copy β€” sometimes useful, lowkey underrated
  • db.in.ogr β€” for importing external tables πŸ¦‹

πŸ‘‘ Supported SQL commands by DBF driver πŸ‘‘

here's the whole roster, exactly as she serves it:

ALTER TABLE table ADD [COLUMN] columndef
ALTER TABLE table DROP COLUMN colname
CREATE TABLE table ( columndefs )
DROP TABLE table
SELECT columns FROM table
SELECT columns FROM table WHERE condition
SELECT columns FROM table ORDER BY column
DELETE FROM table
DELETE FROM table WHERE condition
INSERT INTO table VALUES (value1[,value2,...])
INSERT INTO table ( column1[,column2,...] ) VALUES (value1[,value2,...])
UPDATE table SET assignment1[,assignment2,...]
UPDATE table SET assignment1[,assignment2,...] WHERE condition

✨ Operators available in conditions ✨

the mood board of operators:

  • "=" β€” equal
  • "<" β€” smaller than
  • "<=" β€” smaller/equal than
  • ">" β€” larger than
  • ">=" β€” larger/equal than
  • "<>" β€” not equal
  • "~" β€” Substring matching (non-standard SQL)
  • "%" β€” Substring matching (limited functionality)

a few extra notes so you don't get caught out πŸ™ˆ

Arithmetic expressions using constants and field values are allowed in condition clauses and in the RHS of assignments.

Usual precedence rules and bracketing (using ’(’ and ’)’) are supported.

Type conversion is performed if necessary (experimental). experimental!! just so you know πŸ’€

Conditions allow boolean expressions using the AND, OR and NOT operators, with the usual precedence rules.

NULLs can be tested by ’colname IS NULL’ in conditions. The negation is ’colname NOT NULL’.

Sorting: Empty fields in a character column are sorted to the end. that's just where they go, periodt πŸ’…


πŸ’€ LIMITATIONS OF THE DBF DRIVER πŸ’€

okay this is the part where we keep it real. the DBF driver supports only a few SQL statements, because DBF tables are intended for simple table storage. and DBF column names are limited to 10 characters (as defined in the DBF specifications). for example:

  • aggregate functions (sum, count, min, max,...) are not supported in SELECT clauses;
  • mathematic functions (sin, cos, exp, log,...) are not supported in expressions;
  • SQL query with IN are not supported.

😭 ERROR MESSAGES 😭

if you see something like this:

DBMI-DBF driver error:
SQL parser error: syntax error, unexpected NAME processing ’IN’..

that means you used an unsupported SQL statement (here, ’IN’). the only solution is to switch the DBMI backend to a real SQL engine (SQLite, PostgreSQL, MySQL etc.). See SQL support in GRASS GIS. 🧚

and if you see something like this:

DBMI-DBF driver error:
SQL parser error: syntax error, unexpected DESC, expecting NAME processing ’DESC’

that means a column name corresponds to a reserved SQL word (here: ’DESC’). a different column name should be used. and if this happens during import with v.in.ogr, the cnames parameter can be used to assign different column names on the fly. slay 🫢


🌈 SEE ALSO 🌈

  • db.connect
  • SQL support in GRASS GIS
  • DBF Specifications (Shapelib)

⭐ SOURCE CODE ⭐

Available at: DBF DATABASE DRIVER source code (history)

Accessed: Saturday Jan 17 05:40:32 2026

Main index | Topics index | Keywords index | Graphical index | Full index


and that's the whole page bestie, no notes πŸ’œ this was GRASS GIS 8.4.2 Reference Manual, Β© 2003-2025 GRASS Development Team, version 8.4.2, accessed Saturday Jan 17 05:40:32 2026 β€” go build something cute with it βœ¨πŸŽ€

πŸ“¦ where this page comes from