[GRASS-user] Change SQLite DB Column Width?

Jeshua Lacock jeshua at 3DTOPO.com
Fri Aug 4 15:22:57 PDT 2017


> On Aug 4, 2017, at 2:03 AM, Even Rouault <even.rouault at spatialys.com> wrote:
> 
> As column width is just a hint in SQLite and has no influence on the database structure (you can insert fields that are longer than the declared size), you can just edit the sqlite_master table (which is generaly a dangerous game, and must be done only when you know what you are doing)
>  
> With the sqlite3 shell :
>  
> PRAGMA writable_schema = 1;
> UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE TrailSegment_12(column_definitions_before_name, NAME CHARACTER(128), column_definitions_after_name) ' WHERE NAME = 'TrailSegment_12';
> PRAGMA writable_schema = 0;
>  
> so basically get the existing SQL definitions of the table with "SELECT SQL FROM SQLITE_MASTER WHERE NAME = 'TrailSegment_12'", edit it to change the column width, and put it in the above UPDAT

Hi Even,

Thanks for your help.

If I could figure out exactly what you mean, I think this might be the most elegant solution.

But when I run:

sqlite> SELECT sql FROM sqlite_master WHERE type = 'TrailSegment_12’;
sqlite> 

It doesn’t display anything and just returns to the sqlite prompt.



Best,

Jeshua Lacock
Founder/Engineer
<3DTOPO.com>
GlassPrinted.com



More information about the grass-user mailing list