On Thu, Mar 25, 2010 at 11:41:30PM +0000, David Reynolds wrote:
On 25 Mar 2010, at 23:14, Wayne Stallwood ALUGlist@digimatic.co.uk wrote:
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.
That would be crazy as every time you wanted a different order you would have to re-order the tables and then every time you insert a row, guess what....you would have to re-order the tables again.
The correct way to do this surely is to order results on your queries not on the data itself
SELECT * FROM table ORDER BY column
of course you can also specify multiple columns so if say you wanted to surname and then date of birth then two identical surnames would be ordered with the oldest one first. it's naturally also possible to reverse the order etc
Wayne,
I think Chris was talking about reordering the *columns* not the *rows* ;)
Chris,
You could dump the data, recreate the table with the columns in the order you want and then reimport the data, or you could just use SELECT with the fields in the order you want ;)
Yes, I think that's the only way to do it.
I can do a *little* re-ordering with sqlitebrowser because if I use its ability to add a column to a table the new column is added as the first column whereas if I add a column using ALTER TABLE x ADD COLUMN then the column is added as the last column. Thus with a little work columns can be moved around and, in particular, 'important' columns can be moved to the front.
I'd love to know how sqlitebrowser's internal column editing manages to add columns at the front.