On Fri, Mar 26, 2010 at 10:55:59AM +0000, Brett Parker wrote:
On 26 Mar 10:43, 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.
Doesn't work in SQLite, which would just make the field type...
"varchar(20) after Field2"
Yes. Really.
Well when I tried it I got an error message:-
sqlite> alter table companies add newColumn varchar(20) after Place; SQL error: near "after": syntax error sqlite>
In case one wasn't aware, all fields in sqlite are text. Nothing else. It doesn't do type checking.
Are you sure you're not talking about sqlite version 2? I've just tried putting text into an integer column on a sqlite 3 database and it gives an error:-
sqlite> pragma table_info(Companies); 0|Email|TEXT|0||0 1|Address|TEXT|0||0 2|Place|TEXT|0||0 3|Contact|TEXT|0||0 4|Tel|TEXT|0||0 5|Web|TEXT|0||0 6|Comment|TEXT|0||0 7|Category|TEXT|0||0 8|Name|TEXT|0||0 9|id|INTEGER|0||1 sqlite> select id, name from Companies where Name = 'Landrau'; 60|Landrau sqlite> sqlite> update Companies set id = 'ABCDE' where name = 'Landrau'; SQL error: datatype mismatch sqlite>