[GRASS-user] Re: [GRASS-windows] copy column values

Markus Neteler neteler at osgeo.org
Mon Jun 1 10:12:46 EDT 2009


On Mon, Jun 1, 2009 at 3:59 PM, Stefanie Obmann <stef_ob at gmx.at> wrote:
> Hello again,
>
> Could you please tell me if it’s possible to change a column data type after
> importing it and how? Got just double type data in it, but imported it as
> string.

Yes, you can do that:


Examples of changing a SQL type (type casting, does not work for DBF driver):
# North Carolina data set: convert string column to double precision
#  copy map into current mapset
g.copy vect=geodetic_pts,mygeodetic_pts
v.db.addcol mygeodetic_pts col="zval double precision"

# the 'z_value' col contains 'N/A' strings, not to be converted
v.db.update mygeodetic_pts col=zval \
            qcol="CAST(z_value AS double precision)" \
            where="z_value <> 'N/A'"

Cheers
Markus


More information about the grass-user mailing list