Re: [sqlite] How can I rename a column without ALTER COLUMN Command

2006-04-07 Thread Roman
Hi Dennis,

I followed your path and managed to rebuild my table. All is well in the land 
of Roman now. Thanks again,
Roman

On Friday 07 April 2006 11:57 am, Dennis Cote wrote:
> Roman wrote:
> >http://sqlzoo.net/howto/source/z.dir/tip557646/i02create.xml
> >
> >says that such is not possible
> >
> >On Friday 07 April 2006 11:39 am, Roman wrote:
> >>I know that ALTER TABLE -> ALTER COLUMN is not supported by sqlite3.
> >>
> >>I misspelled a column name, and I am curious if there is a command to
> >>change the name from sqlite3 interface.
> >>
> >>Thanks,
> >>RK
>
> Roman,
>
> Try this:
>
> begin;
> create temp table temp_table as select * from bad_table;
> drop table bad_table;
> create table good_table ( same as existing with correct column name)
> insert into good_table select * from temp_table;
> drop table temp_table;
> commit;
>
> You will also need to recreate any indexes on the table after it is
> dropped.
>
> HTH
> Dennis Cote


Re: [sqlite] How can I rename a column without ALTER COLUMN Command

2006-04-07 Thread Dennis Cote

Roman wrote:


http://sqlzoo.net/howto/source/z.dir/tip557646/i02create.xml

says that such is not possible

On Friday 07 April 2006 11:39 am, Roman wrote:
 


I know that ALTER TABLE -> ALTER COLUMN is not supported by sqlite3.

I misspelled a column name, and I am curious if there is a command to
change the name from sqlite3 interface.

Thanks,
RK
   



 


Roman,

Try this:

begin;
create temp table temp_table as select * from bad_table;
drop table bad_table;
create table good_table ( same as existing with correct column name)
insert into good_table select * from temp_table;
drop table temp_table;
commit;

You will also need to recreate any indexes on the table after it is dropped.

HTH
Dennis Cote


Re: [sqlite] How can I rename a column without ALTER COLUMN Command

2006-04-07 Thread Alex Charyna

Here's what I might do, I'd be curious of the other's answers.

You could use the .dump command, redirect it into a flat file
Use sed to fix the field name in the file.
Delete the old table.
Then load it back in using the corrected dump file.

-alex

On Apr 7, 2006, at 10:39 AM, Roman wrote:


I know that ALTER TABLE -> ALTER COLUMN is not supported by sqlite3.

I misspelled a column name, and I am curious if there is a command  
to change

the name from sqlite3 interface.

Thanks,
RK




Re: [sqlite] How can I rename a column without ALTER COLUMN Command

2006-04-07 Thread Derrell . Lipman
Roman <[EMAIL PROTECTED]> writes:

> I know that ALTER TABLE -> ALTER COLUMN is not supported by sqlite3.
>
> I misspelled a column name, and I am curious if there is a command to change 
> the name from sqlite3 interface.

A bit simplistic, but:

echo ".dump" | \
  sqlite3 database.db | \
  sed 's/old_column_name/new_column_name'/g | \
  sqlite3 newdatabase.db

This assumes you're on Linux or equiv.  If you're using Windows, you should be
able to do something similar with:

  sqlite3 database.db



Re: [sqlite] How can I rename a column without ALTER COLUMN Command

2006-04-07 Thread Roman
http://sqlzoo.net/howto/source/z.dir/tip557646/i02create.xml

says that such is not possible

On Friday 07 April 2006 11:39 am, Roman wrote:
> I know that ALTER TABLE -> ALTER COLUMN is not supported by sqlite3.
>
> I misspelled a column name, and I am curious if there is a command to
> change the name from sqlite3 interface.
>
> Thanks,
> RK