Skip to content

db.dropcolumn

Drops a column from selected attribute table.

db.dropcolumn [-f] table=name column=name [database=name] [driver=name] [--verbose] [--quiet] [--qq] [--ui]

Example:

db.dropcolumn table=name column=name

grass.script.run_command("db.dropcolumn", table, column, database=None, driver=None, flags=None, verbose=None, quiet=None, superquiet=None)

Example:

gs.run_command("db.dropcolumn", table="name", column="name")

grass.tools.Tools.db_dropcolumn(table, column, database=None, driver=None, flags=None, verbose=None, quiet=None, superquiet=None)

Example:

tools = Tools()
tools.db_dropcolumn(table="name", column="name")

This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

Parameters

table=name [required]
    Name of attribute table
column=name [required]
    Name of attribute column
database=name
    Name of database
driver=name
    Name of database driver
    Allowed values: dbf, odbc, ogr, sqlite, pg
-f
    Force removal (required for actual deletion of files)
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

table : str, required
    Name of attribute table
    Used as: input, dbtable, name
column : str, required
    Name of attribute column
    Used as: input, dbcolumn, name
database : str, optional
    Name of database
    Used as: input, dbname, name
driver : str, optional
    Name of database driver
    Used as: input, dbdriver, name
    Allowed values: dbf, odbc, ogr, sqlite, pg
flags : str, optional
    Allowed values: f
    f
        Force removal (required for actual deletion of files)
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

table : str, required
    Name of attribute table
    Used as: input, dbtable, name
column : str, required
    Name of attribute column
    Used as: input, dbcolumn, name
database : str, optional
    Name of database
    Used as: input, dbname, name
driver : str, optional
    Name of database driver
    Used as: input, dbdriver, name
    Allowed values: dbf, odbc, ogr, sqlite, pg
flags : str, optional
    Allowed values: f
    f
        Force removal (required for actual deletion of files)
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

Returns:

result : grass.tools.support.ToolResult | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None will be returned.

DESCRIPTION

db.dropcolumn drops a column from an attribute table. If the -f force flag is not given then nothing is removed, instead a preview of the action to be taken is printed.

NOTES

db.dropcolumn is a front-end to db.execute to allow easier usage with a special workaround for the SQLite driver to support column drop also for SQLite tables.

EXAMPLE

Dropping a column (North Carolina sample dataset):

# work on own copy
g.copy vect=roadsmajor,myroads
db.describe -c myroads

# only shows what would happen:
db.dropcolumn myroads column=SHAPE_LEN

# actually drops the column
db.dropcolumn -f myroads column=SHAPE_LEN

db.describe -c myroads

SEE ALSO

db.describe, db.droptable, db.execute, v.db.dropcolumn, GRASS SQL interface

AUTHOR

Markus Neteler

SOURCE CODE

Available at: db.dropcolumn source code (history)
Latest change: Wednesday Mar 12 22:27:28 2025 in commit 0095480