On Fri, Mar 26, 2010 at 12:31:09PM +0000, Chris Glover wrote:
On 26/03/2010 12:26, Chris G wrote:
On Fri, Mar 26, 2010 at 10:43:33AM +0000, simon ransome wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Chris G wrote:
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.
If it's anything like MySQL, then you can specify a FIRST or AFTER modifyer, e.g. given
Field1 Field2 Field3 Field4
then
alter table mytable add Field2andahalf varchar(20) after Field2;
would stick the new field between Field2 and Field3.
No, sqlite3 won't have that, it just says 'near "after": syntax error'.
Hi Chris,
You could create a view with the columns ordered as you want, then do your selects on the view instead.
eg
CREATE VIEW viewname AS SELECT column1,column2,column3 FROM tablename WHERE....
then SELECT * FROM viewname will give you the columns in the order you want.
That's a point, I'd not thought of using views, thank you.