Yes currently it depends on the order. Should be checking if it can be
avoided.

The issue has been resolved by the method you've suggested (INSERT INTO
new_table (col_1, col_3)
SELECT col_1, col_2 FROM old_table;)

Thanks to everyone!!

I am looking for how to get total no.of columns even if the table is empty..

Thanks,
Sabapathy


Pavel Ivanov-2 wrote:
> 
>> But I came to know that new columns can be added only at the end.
>> So I have to create an empty table in new format and insert the records
>> from
>> old table & delete the old table(?).
> 
> Are you sure that your software tool depends on the order of columns
> in the database? Even if new version creates necessary table with new
> columns in the middle it could be written in the way that it doesn't
> matter what's the actual order of columns. And if it really depends on
> the order of columns then I'd say it's poorly written application and
> it can be filed as bug report. Especially if it doesn't support
> automatic upgrade from old database format.
> 
>> How can I do this efficiently even if there are tens of thousands of
>> records..?
> 
> I believe the only quick and efficient way to do that is INSERT INTO
> ... SELECT ...
> 
>> Can I provide mapping of columns to insert from one table to another?
>> (For eg, if the old table has 2 columns & new one 3 columns, I want to
>> insert 1st column to 1st column, 2nd to 3rd and leave 2nd column empty in
>> new table)
> 
> INSERT INTO new_table (col_1, col_3)
> SELECT col_1, col_2 FROM old_table;
> 
> 
> Pavel
> 
> On Mon, Apr 19, 2010 at 1:47 PM, sabapathy <sabapathy...@rediffmail.com>
> wrote:
>>
>> The DB had some 15 columns before.
>> And there are lot of records saved using the s/w tool.
>> But in the latest version of tool there are some columns added in DB
>> inbetween of existing columns.
>> So to use the DB saved using previous version of tool, I need to add some
>> columns(blank) in between in the old DB.
>> But I came to know that new columns can be added only at the end.
>> So I have to create an empty table in new format and insert the records
>> from
>> old table & delete the old table(?).
>> How can I do this efficiently even if there are tens of thousands of
>> records..?
>>
>> Can I provide mapping of columns to insert from one table to another?
>> (For eg, if the old table has 2 columns & new one 3 columns, I want to
>> insert 1st column to 1st column, 2nd to 3rd and leave 2nd column empty in
>> new table)
>>
>> Thanks..
>> --
>> View this message in context:
>> http://old.nabble.com/Inserting-from-other-table-tp28287723p28287723.html
>> Sent from the SQLite mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Inserting-from-other-table-tp28287723p28367790.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to