.TH v.db.update 1grass "" "GRASS 7.8.5" "GRASS GIS 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, attribute table, database, attribute update, type casting .SH SYNOPSIS \fBv.db.update\fR .br \fBv.db.update \-\-help\fR .br \fBv.db.update\fR \fBmap\fR=\fIname\fR \fBlayer\fR=\fIstring\fR \fBcolumn\fR=\fIname\fR [\fBvalue\fR=\fIstring\fR] [\fBquery_column\fR=\fIname\fR] [\fBwhere\fR=\fIsql_query\fR] [\fBsqliteextra\fR=\fIname\fR] [\-\-\fBhelp\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] [\-\-\fBui\fR] .SS Flags: .IP "\fB\-\-help\fR" 4m .br Print usage summary .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .IP "\fB\-\-ui\fR" 4m .br Force launching GUI dialog .SS Parameters: .IP "\fBmap\fR=\fIname\fR \fB[required]\fR" 4m .br Name of vector map .br Or data source for direct OGR access .IP "\fBlayer\fR=\fIstring\fR \fB[required]\fR" 4m .br Layer number or name .br Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name. .br Default: \fI1\fR .IP "\fBcolumn\fR=\fIname\fR \fB[required]\fR" 4m .br Name of attribute column to update .IP "\fBvalue\fR=\fIstring\fR" 4m .br Literal value to update the column with .IP "\fBquery_column\fR=\fIname\fR" 4m .br Name of other attribute column to query, can be combination of columns (e.g. co1+col2) .IP "\fBwhere\fR=\fIsql_query\fR" 4m .br WHERE conditions of SQL statement without \(cqwhere\(cq keyword .br Example: income < 1000 and population >= 10000 .IP "\fBsqliteextra\fR=\fIname\fR" 4m .br Name of SQLite extension file for extra functions (SQLite backend only) .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 allows updating 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 .SS Replacing of NULL values 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: .br .nf \fC g.copy vect=lakes,mylakes v.db.select mylakes v.db.select mylakes where=\(dqFTYPE IS NULL\(dq # display the lakes, show undefined FTYPE lakes in red g.region vector=mylakes d.mon wx0 d.vect mylakes where=\(dqFTYPE NOT NULL\(dq type=area col=blue d.vect mylakes where=\(dqFTYPE IS NULL\(dq type=area col=red # replace NULL with FTYPE WETLAND v.db.update mylakes col=FTYPE value=WETLAND \(rs where=\(dqFTYPE IS NULL\(dq v.db.select mylakes \fR .fi .SS Updating of columns with on the fly calculation Spearfish example: adding new column, copying values from another table column with on the fly calculation: .br .nf \fC g.copy vect=fields,myfields v.db.addcolumn myfields col=\(dqpolynum integer\(dq v.db.update myfields col=polynum qcol=\(dqcat*2\(dq v.db.select myfields \fR .fi .SS Type casting Type cast (type conversion) of strings to double precision (unsupported by DBF driver): .br .nf \fC g.copy vect=geodetic_pts,mygeodetic_pts v.db.update mygeodetic_pts col=zval qcol=\(dqCAST(z_value AS double precision)\(dq \(rs where=\(dqz_value <> \(cqN/A\(cq\(dq \fR .fi .SS Updating of columns with on the fly calculation (SQLite extended functions) Note: this requires SQLite extended functions. For details see the GRASS GIS Wiki (compilation of libsqlitefunctions.so and libsqlitefunctions.dll). .PP North Carolina data set example: adding new column, copying values from another table column with on the fly calculation: .br .nf \fC g.copy vect=precip_30ynormals,myprecip_30ynormals v.db.addcolumn myprecip_30ynormals column=\(dqlogjuly double precision\(dq v.db.update myprecip_30ynormals column=\(dqlogjuly\(dq query_column=\(dqlog(jul)\(dq \(rs sqliteextra=$HOME/sqlite_extensions/libsqlitefunctions.so v.db.select myprecip_30ynormals columns=jul,logjuly jul|logjuly 132.842|4.88916045210132 127|4.84418708645859 124.206|4.82194147751127 104.648|4.65060233738593 98.298|4.58800368106618 \&... \fR .fi .SH SEE ALSO \fI db.execute, v.db.addcolumn, 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) .SH SOURCE CODE .PP Available at: v.db.update source code (history) .PP Main index | Vector index | Topics index | Keywords index | Graphical index | Full index .PP © 2003\-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual