[GRASSLIST:9807] Re: Solved: way to drop column in sqlite3
wqual
wolfgang.qual at gmx.net
Thu Jan 12 09:18:25 EST 2006
Hi Stephan,
I placed it into the TWiki:
http://grass.gdf-hannover.de/twiki/bin/view/GRASS/SqliteDropcolumn
Am Donnerstag 12 Januar 2006 pH:47:14 nachmittags/abends schrieb Stephan Holl:
> Hello Wolfgang,
>
> On Thu, 12 Jan 2006 14:00:36 +0100 wqual <wolfgang.qual at gmx.net> wrote:
> > Hi list,
> > I just found out that there is a way to drop columns in sqlite. It is
> > not this alter table drop column command, but another one [1]
> >
> > "BEGIN TRANSACTION;
> > CREATE TEMPORARY TABLE t1_backup(a,b);
> > INSERT INTO t1_backup SELECT a,b FROM t1;
> > DROP TABLE t1;
> > CREATE TABLE t1(a,b);
> > INSERT INTO t1 SELECT a,b FROM t1_backup;
> > DROP TABLE t1_backup;
> > COMMIT;"
> >
> > It's obvious that this is a little bit complex. But if you use
> > sqlitebrowser, you will find under -->modify table a button "remove
> > field".
> >
> > Best regards,
> >
> > Wolfgang
> >
> >
> > [1] http://www.sqlite.org/faq.html#q13
>
> Nice one. I think this should find the way into the GRASS-wiki on [1].
>
> What do you think?
>
> Best
> Stephan
>
> [1] http://grass.gdf-hannover.de/
>
> > ----------------------
> >
> > Am Dienstag 10 Januar 2006 pH:20:16 nachmittags/abends schrieb
> >
> > Wolfgang Qual:
> > > Hi everybody,
> > > I just read that SQLITE also does not support "ALTER TABLE table
> > > DROP COLUMN". ("SQLite's version of the ALTER TABLE command allows
> > > the user to rename or add a new column to an existing table. It is
> > > not possible to remove a column from a table." [1]
> > > How to deal with this issue?
> > >
> > > Best regards,
> > > Wolfgang
> > >
> > > [1] http://www.sqlite.org/lang_altertable.html
> > >
> > > -----
> > >
> > > > --- Ursprüngliche Nachricht ---
> > > > Von: M S <mseibel at gmail.com>
> > > > An: Markus Neteler <neteler at itc.it>
> > > > Kopie: GRASS Users List <grasslist at baylor.edu>
> > > > Betreff: [GRASSLIST:9717] Re: drop column?
> > > > Datum: Wed, 4 Jan 2006 12:06:46 -0500
> > > >
> > > > yes sorry, that was for the DBF driver. shoot, thats too bad. i
> > > > guess i'd have to (from reading the archives) create a temp table
> > > > and copy over only the colums I want and then re-attach it? that
> > > > might be a handy function.
> > > >
> > > > anyhow, learning postgres is on my TODO list, so hopefully this
> > > > issue goes away with more knowledge.
> > > >
> > > > thanks!
> > > >
> > > > On 1/4/06, Markus Neteler <neteler at itc.it> wrote:
> > > > > M S wrote:
> > > > > >is there a drop column command? i didnt see one in the man
> > > > > >pages, and when i tried the "ALTER TABLE table DROP COLUMN
> > > > > >column_name" | db.execute it didnt like that command but i
> > > > > >was able to add columns..
> > > > >
> > > > > It depends on the DB driver. I assume that you use DBF? Then it
> > > > > doesn't work since DBF is very limited. For all other drivers
> > > > > it should
> > > >
> > > > (untested).
> > > >
> > > > > Markus
More information about the grass-user
mailing list