SQL rename columns: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(new article)
 
m (Reverted edits by Reverse22 (talk) to last revision by Neteler)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Q: I have imported successfully a large dataset to GRASS. After the import, the attribute columns are named like this: dbl_1 dbl_2...... I would like to change these names to something more friendly. I've tried some dbf editors but they allow only to change values but not the database structure.
''Q: I have imported successfully a large dataset to GRASS. After the import, the attribute columns are named like this: dbl_1 dbl_2...... I would like to change these names to something more friendly. I've tried some dbf editors but they allow only to change values but not the database structure.''


A: You can change column names with [http://openoffice.org Openoffice.org] (Version 2). But take care to use 'oobase' (or: File -> New -> Database) to avoid problems with the number of rows. So, use 'oobase' to connect to your dbf file using the dbase driver (in the launch dialog chose "connect to existing database"). Then you don't have any problems with row number limits.
'''A:''' You can change column names with [http://openoffice.org Openoffice.org] (Version 2). But take care to use 'oobase' (or: File -> New -> Database) to avoid problems with the number of rows. So, use 'oobase' to connect to your dbf file using the dbase driver (in the launch dialog chose "connect to existing database"). Then you don't have any problems with row number limits.


Notes:
Notes:
* In PostgreSQL there is an ALTER TABLE/RENAME COLUMN command.
* In PostgreSQL there is an ALTER TABLE/RENAME COLUMN command.
* For SQLite, use the [http://sqlitebrowser.sourceforge.net/ sqlitebrowser] browser.
* For SQLite, use the [http://sqlitebrowser.sourceforge.net/ SQLiteBrowser] program or the [https://addons.mozilla.org/en-US/firefox/addon/5817 Firefox SQLite Manager plugin].
 
Alternative: in GRASS >=6.3 there is drop column support: so you can add a new column, update it to the one to be renamed, drop the old column.
* {{cmd|v.db.renamecol}}
* {{cmd|v.db.dropcol}}
* {{cmd|v.db.addcol}}


=== See also ===
=== See also ===

Latest revision as of 21:35, 30 December 2011

Q: I have imported successfully a large dataset to GRASS. After the import, the attribute columns are named like this: dbl_1 dbl_2...... I would like to change these names to something more friendly. I've tried some dbf editors but they allow only to change values but not the database structure.

A: You can change column names with Openoffice.org (Version 2). But take care to use 'oobase' (or: File -> New -> Database) to avoid problems with the number of rows. So, use 'oobase' to connect to your dbf file using the dbase driver (in the launch dialog chose "connect to existing database"). Then you don't have any problems with row number limits.

Notes:

Alternative: in GRASS >=6.3 there is drop column support: so you can add a new column, update it to the one to be renamed, drop the old column.

See also