Android Question Alter a SQLite Table by Adding a Column Not at the End of the List

Mahares

Expert
Licensed User
Longtime User
According to the SQLite documentation: 'The new column is always appended to the end of the list of existing columns.'
Is there any way to change the placement of a column within a table after it is appended without having to create a new table, append to it the records from the source table, then delete the source table and rename the destination table?
I thought it may be beneficial at times when you have a delimited text file without a header that needs to be appended to an altered table but the text file columns have a set order.
Thank you
 

barx

Well-Known Member
Licensed User
Longtime User
Not that I'm aware of, you would need to create new table with new column(s) and the transfer data from old to new. Finally delete old table.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
WHAT does it change then? which parameters?
SQLDBUtils- that ı use
so ı want to add new columns or change names or anything else like that BUUUT I CAN NOT


I'd like to add new BİRTHDAY column but
I couldn
pLEse HELP


upload_2014-2-21_16-12-14.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You can find on the site that this has already happened to other members.

At that moment, the query points to a different DB, in which the Person table does not contain the Birthdate field.

verification:
is to run a query that lists the names of the fields in the table ... a moment that I search it
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
I am beginer at DB ,so
ı research so much . Is there any example file/zip which ı can excess. if there is it ,how can ı reach them .

ı think the program cannot read the changes on the table , ı 'll try to create a new table myself :/
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
I ve never tried before , I am trying to do at this time , after ı finish ı 'll let you know . I hope it works :/
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
the query is a little complicated (I should post a whole routine) but the problem remains the same: your query interrogates a version of the DB that does not contain that field in that table.

(I have not read all the posts, now I try to do it. In the meantime, given the indication, check the db)
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
I download it from this blog which is given in examples. I thought if ı change columns, ,it's name , order , ı hope it does change too. on program query as well . Maybe my information is not enough yet for that. ı do not know .
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
There is no change :(
It made me sad , if ı learn how to change any part of the db. MAYBE I could handle it , but ı do not know how to do on this file.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
If I handle it, I 'll look for adding a photo to db . like a normal personal card . That 's what ı want . that's all . :)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The db contains the field Birthday!

The error you posted was on the Activity_Resume Edit the module but now it is empty.

Unfortunately I can not run the project, I have the previous version of B4A.

However, when you change the structure of the db, copy it directly in the Files folder of the project, because these 3 lines of code:
B4X:
If File.Exists (File.DirDefaultExternal, DBFileName) = False Then
DBFileDir = DBUtils.CopyDBFromAssets (DBFileName)
end If

found a DB in the folder and do not copy the new version you've added to the Files tab.

(Sorry, at this moment I do not have any more time :()
 
Upvote 0
Top