[GRASS-user] Change SQLite DB Column Width?

Vincent Bain bain at toraval.fr
Thu Aug 3 22:52:59 PDT 2017


Hello Jeshua,

to my knowledge, no way to alter a column in sqlite3 :
https://www.sqlite.org/lang_altertable.html

.width only affects the output width of columns within sqlite3 prompt.

I would suggest you to simply add a new column (with the right width),
then copy the content of the previous to the new one and trash the
former.


Hope this helps,
Vincent.

Le jeudi 03 août 2017 à 17:19 -0600, Jeshua Lacock a écrit :
> Greetings,
> 
> I am attempting to patch vectors together with v.patch -e (I need the attributes). But I am getting this error:
> 
> ERROR: Length of string columns differ
> 
> Upon inspecting the columns, I see that at least one vector has a NAME column with a width of 120 characters, while most of them have a width of 80:
> 
> 
> > db.describe  table=TrailSegment_12
> 
> column:NAME
> description:
> type:CHARACTER
> len:120
> scale:0
> precision:0
> default:
> nullok:yes
> select:?
> update:?
> 
> Is it possible to change the width of the columns? The DB is SQLite.
> 
> I tried altering the width using db.execute and this SQL:
> 
> ALTER TABLE TrailSegment_12
> ALTER COLUMN NAME CHARACTER(128)
> 
> But I get the errors:
> 
> DBMI-SQLite driver error:
> Error in sqlite3_prepare():
> near "TrailSegment_Michigan": syntax error
> 
> DBMI-SQLite driver error:
> Error in sqlite3_prepare():
> near "TrailSegment_Michigan": syntax error
> 
> ERROR: Error while executing: 'ALTER TABLE TrailSegment_12'
> 
> Seems like there must be a way. I found SQLite has a .width command, but I am not sure how to use it.
> 
> 
> Thanks,
> 
> Jeshua Lacock
> Founder/Engineer
> <3DTOPO.com>
> GlassPrinted.com
> 
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user




More information about the grass-user mailing list