v.db.addtable(1grass)

πŸ’– v.db.addtable πŸ’– (that's the manual page name bestie, v.db.addtable(1grass), from the GRASS User's Manual)

✨ NAME ✨

okay so v.db.addtable makes a brand new attribute table and hooks it up to whichever layer of an existing vector map you point at. it's giving matchmaker 🫢


🏷️ KEYWORDS

vector, attribute table, database


πŸ“œ SYNOPSIS

v.db.addtable
v.db.addtable --help
v.db.addtable map=name  [table=string]   [layer=integer]   [key=name]
[columns=name type[,name type,...]]   [--help]  [--verbose]  [--quiet]
[--ui]

🚩 Flags

  • --help β€” prints the usage summary, the classic "what do i even type" rescue πŸ™ˆ
  • --verbose β€” verbose module output, she's chatty πŸ’¬
  • --quiet β€” quiet module output, she's mysterious 🀫
  • --ui β€” forces the GUI dialog to launch, main character energy in a window πŸͺŸ

πŸŽ€ Parameters

  • map=name [required] β€” the name of the vector map. can also be a data source for direct OGR access, iykyk
  • table=string β€” name of the new attribute table. default? the vector map name, cute and convenient ✨
  • layer=integer β€” which layer number you want the new attribute table on. default: 1
  • key=name β€” name of the key column, and no cap it must refer to an integer column. default: cat 🐱
  • columns=name type[,name type,...] β€” name and type of the new column(s), written like 'name type [,name type, ...]'. the types depend on your database backend, but literally all of them support VARCHAR(), INT, DOUBLE PRECISION and DATE. example: 'label varchar(250), value integer'

πŸ“– DESCRIPTION

v.db.addtable creates a new attribute table and adds it to a given vector map. it links that table to the layer you specified. and if your vector map isn't linked to any table yet? don't stress β€” a new database link gets established based on the MAPSET database settings (go peek at db.connect) πŸ’…


πŸ—’οΈ NOTES

v.db.addtable is basically a front-end to db.execute, there to make your life easier. obsessed with the convenience honestly.

here's the tea though: v.db.addtable will only insert category values into the table for those features which actually have a category value in the relevant layer. so if you want those category values in there, you can add them automatically with v.category, or do it manually with the wxGUI vector digitizer, before you run v.db.addtable. or flip the order β€” run v.db.addtable first, then use either a combination of v.category + v.to.db, or the wxGUI vector digitizer, to add the relevant lines into the table. both paths eat, pick your fighter πŸ“

the supported types of columns depend on the database backend. however, all backends should support VARCHAR, INT, DOUBLE PRECISION and DATE ⭐

and if you wanna double check the existing database connection(s), just verify them with v.db.connect.


🌈 EXAMPLE

adding a new attribute table with a single column to default layer 1:

g.copy vect=roadsmajor,myroads
v.db.addtable myroads columns="slope double precision"
v.db.connect -p myroads
v.info -c myroads

adding a new attribute table with two columns to layer 2:

g.copy vect=roadsmajor,myroads
v.db.addtable myroads columns="slope double precision, roadname varchar(15)" layer=2
v.db.connect -p myroads
v.info -c myroads
v.info -c myroads layer=2

πŸ‘€ SEE ALSO

db.connect, db.droptable, db.execute, v.db.connect, v.db.dropcolumn, v.db.droptable, v.db.select, v.db.update

GRASS SQL interface


πŸ‘‘ AUTHOR

Markus Neteler


πŸ”— SOURCE CODE

available at: v.db.addtable source code (history)

latest change: Monday Aug 11 18:59:23 2025 in commit: edc87a4920570efe1d80b06033a435fc2f419d8f

Main index | Vector 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, you ate πŸ’…βœ¨ this was brought to you by GRASS 8.5.0, so when you're done slaying your attribute tables just remember where you got the lore πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from