1db.execute(1)                 Grass User's Manual                db.execute(1)
2
3
4

NAME

6       db.execute  - Execute any SQL statement.
7

KEYWORDS

9       database, SQL
10

SYNOPSIS

12       db.execute
13       db.execute help
14       db.execute [-i]  [input=filename]   [driver=string]   [database=string]
15
16   Flags:
17       -i  Ignore SQL errors and continue
18
19   Parameters:
20       input=filename
21           File containing SQL statements
22
23       driver=string
24           Driver name Options: dbf,mysql,ogr,pg,sqlite,mesql,odbc
25
26       database=string
27           Database name
28

DESCRIPTION

30       db.execute allows the user to execute SQL statements.
31

NOTES

33       If  parameters for database connection are already set with db.connect,
34       they are taken as default values and do not need to be  specified  each
35       time.
36
37       If  you have a large number of SQL commands to process, it is much much
38       faster to place all the SQL statements into a text file and use db.exe‐
39       cute's  input file parameter than it is to process each statement indi‐
40       vidually in a loop. If multiple instruction lines are given,  each  SQL
41       line must end with a semicolon.
42
43       Please  see  the  individual  sql  driver pages for how to create a new
44       database.
45

EXAMPLES

47       Create a new table with columns 'cat' and 'soiltype':
48
49       echo 'create table  soils  (cat  integer,  soiltype  varchar(10)  )'  |
50       db.execute
51
52
53       Create a new table using a file with SQL statements:
54
55       db.execute driver=odbc database=g60test input=file.sql
56
57
58       Insert new row into attribute table:
59
60       echo    "INSERT    INTO    nobugs   (id,name,east_gb,north_gb)   values
61       (30,'Ala',1657340,5072301)" | db.execute
62
63
64       Update attribute entries to new value based on SQL rule:
65
66       echo "UPDATE roads SET travelcost=5 WHERE cat=1" | db.execute
67
68
69       Update attribute entries to new value based on SQL rule:
70
71       echo "UPDATE dourokukan SET testc=50 WHERE testc is NULL" | db.execute
72
73
74       Delete selected rows from attribute table:
75
76       echo "DELETE FROM gsod_stationlist WHERE latitude < -91" | db.execute
77
78
79       Add new column to attribute table:
80
81       echo "ALTER TABLE roads ADD COLUMN length double" | db.execute
82
83
84       Drop table (not supported by all drivers)
85
86       echo "DROP TABLE fmacopy" | db.execute
87
88
89       Update  attribute  with  multiple  SQL  instructions  in  file   (e.g.,
90       file.sql, instruction line must end with a semicolon):
91
92       UPDATE roads SET travelcost=5 WHERE cat=1;
93       UPDATE roads SET travelcost=2 WHERE cat=2;
94
95       cat file.sql | db.execute
96
97

SEE ALSO

99       db.columns, db.describe, db.drivers, db.droptable, db.login, db.select,
100       db.tables, GRASS SQL interface
101

AUTHOR

103       CERL
104
105       Last changed: $Date: 2007/05/17 08:55:11 $
106
107       Full index
108
109
110
111GRASS 6.2.2                                                      db.execute(1)
Impressum