NAME
db.execute - Execute any SQL statement.
SYNOPSIS
db.execute
db.execute help
db.execute [-i] [driver=string] [database=string] [input=string]
Flags:
- -i
- ignore SQL errors and continue
Parameters:
- driver=string
- driver name
- Options: dbf,pg,ogr
- database=string
- database name
- input=string
- filename with sql statement
DESCRIPTION
db.execute allows the user to execute SQL statements.
NOTE
If parameters for database connection are already set with
db.connect, they are taken as default values and
do not need to be spcified each time.
EXAMPLES
Create a new table with columns 'cat' and 'soiltype':
echo 'create table soils ("cat" int, "soiltype" text)' | db.execute
or
cat file.sql | db.execute
Create a new table using a file with SQL statements:
db.execute driver=odbc database=g51test
input=file.sql
Update attribute entries to new value based on SQL rule:
echo "UPDATE roads SET travelcost=5 WHERE cat=1" | db.execute
Update attribute entries to new value based on SQL rule:
echo "UPDATE dourokukan SET testc=50 WHERE testc is NULL" | db.execute
Add new column to attribute table:
echo "ALTER TABLE roads ADD COLUMN length double" | db.execute
Drop table (not supported by all drivers)
echo "DROP TABLE fmacopy" | db.execute
SEE ALSO
db.columns,
db.describe,
db.drivers,
db.droptable,
db.login,
db.select,
db.tables,
GRASS SQL interface
AUTHOR
CERL
Last changed: $Date: 2005/02/12 15:35:04 $
Help Index