On 25 Mar 20:00, Chris G wrote:
I know it isn't really necessary as it doesn't actually affect anything (except my sensibilities) but I'd like the ability to re-order columns in some sqlite databases.
Well, it *does* have some advantages, it would mean I can do things like "SELECT * FROM database" and get the columns displayed in the order I want rather than the order resulting from database creation followed by adding extra columns as I found I needed them.
So, is there any way to re-order columns other than by creating a new table with the required column order, copying all the data across, deleting the old table and renaming the new one?
I can't find any neat utilities out there to do this for me.
When are you using a sqlite database and interfacing to it with something that isn't a programming language? Most languages with a database api will allow you to collect results from the database in a 'hashmap' or 'dictionary' with the column name as the key.
Also, if you're adding lots of columns, you probably want to be more selective which are displayed if you are accessing it from the command line sqlite program, i.e. using: SELECT field1,field2 from mytable where <some condition>; Rather than the * approach.
Thanks,