For complex SQL UPDATE statements, db.execute should be used.
g.copy vect=lakes,mylakes
v.db.select mylakes
v.db.select mylakes where="FTYPE IS NULL"
# display the lakes, show undefined FTYPE lakes in red
g.region vect=mylakes
d.mon x0
d.vect mylakes where="FTYPE NOT NULL" type=area col=blue
d.vect mylakes where="FTYPE IS NULL" type=area col=red
# replace NULL with FTYPE WETLAND
v.db.update mylakes col=FTYPE value=WETLAND \
where="FTYPE IS NULL"
v.db.select mylakes
Spearfish example: adding new column, copying values from other table column with on the fly calculation:
g.copy vect=fields,myfields v.db.addcol myfields col="polynum integer" v.db.update myfields col=polynum qcol="cat*2" v.db.select myfields
Type cast (type conversion) of strings to double precision (unsupported by DBF driver):
g.copy vect=geodetic_pts,mygeodetic_pts
v.db.update mygeodetic_pts col=zval qcol="CAST(z_value AS double precision)" \
where="z_value <> 'N/A'"
Last changed: $Date: 2013-05-02 02:29:18 -0700 (Thu, 02 May 2013) $