db.copy.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <h2>DESCRIPTION</h2>
  2. <em>db.copy</em> allows the user to copy a table between two databases.
  3. Databases can be connected through different drivers (see example).
  4. <h2>NOTES</h2>
  5. Attribute tables can be copied using <em>db.copy</em> and, when to be
  6. associated to a vector map, assigned to the map with
  7. <em><a href="v.db.connect.html">v.db.connect</a></em>. Current connection
  8. settings are saved in the file <em>$LOCATION/vector_map/dbln</em>.
  9. <h2>EXAMPLES</h2>
  10. <h3>DBF -> PG</h3>
  11. <em>Storing table 'geonames.dbf' (in current directory) into PostgreSQL
  12. through ODBC:</em><br>
  13. <div class="code"><pre>
  14. db.copy from_driver=dbf from_database='$GISDBASE/$LOCATION_NAME/PERMANENT/dbf' \
  15. from_table=geonames to_driver=pg to_database="host=pgserver,dbname=testdb" \
  16. to_table=geonames
  17. </pre></div>
  18. <h3>PG -> DBF</h3>
  19. <div class="code"><pre>
  20. db.copy from_driver=pg from_database="host=pgserver.example.org,dbname=testdb" \
  21. from_table=origtable to_driver=dbf \
  22. to_database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf' to_table=origtable
  23. </pre></div>
  24. <h3>PG -> PG with condition</h3>
  25. <div class="code"><pre>
  26. db.copy from_driver=pg from_database="host=localhost,dbname=testdb" \
  27. from_table=geonames to_driver=pg to_database="host=localhost,dbname=testdb" \
  28. to_table=selection where="cat &lt; 500"
  29. </pre></div>
  30. <h3>DBF -> SQLite</h3>
  31. <div class="code"><pre>
  32. db.copy from_driver=dbf from_database='$GISDBASE/$LOCATION_NAME/PERMANENT/dbf' \
  33. from_table=geonames_features to_driver=sqlite \
  34. to_database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db' to_table=geonames_features
  35. # convenient viewer:
  36. sqlitebrowser $HOME/grassdata/nc_spm_08/user1/sqlite/sqlite.db
  37. </pre></div>
  38. <h3>SQLite -> DBF</h3>
  39. <div class="code"><pre>
  40. db.copy from_driver=sqlite from_database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db' \
  41. from_table=ammprv to_driver=dbf to_database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/' \
  42. to_table=ammprv
  43. </pre></div>
  44. <h2>SEE ALSO</h2>
  45. <em>
  46. <a href="db.connect.html">db.connect</a>,
  47. <a href="db.drivers.html">db.drivers</a>,
  48. <a href="db.login.html">db.login</a>,
  49. <a href="v.db.connect.html">v.db.connect</a>,
  50. <a href="v.clean.html">v.clean</a>,
  51. <a href="sql.html">GRASS SQL interface</a>
  52. </em>
  53. <h2>AUTHOR</h2>
  54. Radim Blazek, ITC-irst, Trento, Italy
  55. <p><i>Last changed: $Date$</i>