.TH v.db.update 1grass "" "GRASS 6.4.4" "Grass User's Manual" .SH NAME \fI\fBv.db.update\fR\fR - Updates a column in the attribute table connected to a vector map. .SH KEYWORDS vector, database, attribute table .SH SYNOPSIS \fBv.db.update\fR .br \fBv.db.update help\fR .br \fBv.db.update map\fR=\fIstring\fR [\fBlayer\fR=\fIstring\fR] \fBcolumn\fR=\fIstring\fR [\fBvalue\fR=\fIstring\fR] [\fBqcolumn\fR=\fIstring\fR] [\fBwhere\fR=\fIstring\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] .SS Parameters: .IP "\fBmap\fR=\fIstring\fR" 4m .br Vector map to edit the attribute table for .IP "\fBlayer\fR=\fIstring\fR" 4m .br Layer to which the table to be changed is connected .br Default: \fI1\fR .IP "\fBcolumn\fR=\fIstring\fR" 4m .br Column to update .IP "\fBvalue\fR=\fIstring\fR" 4m .br Literal value to update the column with .br Varchar values must be in single quotes, e.g. 'grass' .IP "\fBqcolumn\fR=\fIstring\fR" 4m .br Name of attribute column to query .br Can be a combination of columns, e.g. col1+col2 .IP "\fBwhere\fR=\fIstring\fR" 4m .br WHERE conditions for update, without 'where' keyword (e.g. cat=1 or col1/col2>1) .PP .SH DESCRIPTION \fIv.db.update\fR assigns a new value to a column in the attribute table connected to a given map. The \fIvalue\fR parameter updates with a literal value. Alternatively, with the \fIqcol\fR parameter values can be copied from another column in the table or be the result of a combination or transformation of other columns. .SH NOTES \fIv.db.update\fR is just a front-end to \fIdb.execute\fR to allow easier usage. .PP For complex SQL UPDATE statements, \fIdb.execute\fR should be used. .SH EXAMPLES In this example, selectively display lakes without (blue) and with NULL (red) are shown to find out which type is undefined. In the original map there are lakes missing FTYPE attribute which are wetlands along streams. These NULL attributes are replaced with the landuse type WETLAND: \fC .DS .br g.copy vect=lakes,mylakes .br v.db.select mylakes .br v.db.select mylakes where="FTYPE IS NULL" .br .br # display the lakes, show undefined FTYPE lakes in red .br g.region vect=mylakes .br d.mon x0 .br d.vect mylakes where="FTYPE NOT NULL" type=area col=blue .br d.vect mylakes where="FTYPE IS NULL" type=area col=red .br .br # replace NULL with FTYPE WETLAND .br v.db.update mylakes col=FTYPE value=WETLAND \(rs .br where="FTYPE IS NULL" .br v.db.select mylakes .br .DE \fR .PP Spearfish example: adding new column, copying values from other table column with on the fly calculation: \fC .DS .br g.copy vect=fields,myfields .br v.db.addcol myfields col="polynum integer" .br v.db.update myfields col=polynum qcol="cat*2" .br v.db.select myfields .br .DE \fR .PP Type cast (type conversion) of strings to double precision (unsupported by DBF driver): \fC .DS .br g.copy vect=geodetic_pts,mygeodetic_pts .br v.db.update mygeodetic_pts col=zval qcol="CAST(z_value AS double precision)" \(rs .br where="z_value <> 'N/A'" .br .DE \fR .SH SEE ALSO \fI db.execute, v.db.addcol, v.db.addtable, v.db.connect, v.db.droptable, v.db.join, v.db.select .br GRASS SQL interface \fR .SH AUTHOR Moritz Lennert (mlennert@club.worldonline.be) .PP \fILast changed: $Date: 2013-05-02 11:29:18 +0200 (Thu, 02 May 2013) $\fR .PP Full index .PP © 2003-2014 GRASS Development Team