I would like to add an additional table in my existing DB without loss of the data. So dropping the tables and create them new is no option. What is the best way to do that?
As many as you want, within the limits of available disk space. in one Database how many tables can i create? A billion or so, though you will run out of disk space first.
Actually, SQLite will easily do 50,000 or more INSERT statements per second on an average desktop computer. But it will only do a few dozen transactions per second.
SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows these alterations of an existing table: it can be renamed; a column can be renamed; a column can be added to it; or a column can be dropped from it.
It seems to be much easier. I use the SQLiteOpenHelper. So the onCreate() is never been called if the DB already exists. When the version number increases, onUpdate() is called. In onUpdate() I have added my new table with "create table if not exists". From the documentation of SQLITE.ORG: However, if the "IF NOT EXISTS" clause is specified as part of the CREATE TABLE statement and a table or view of the same name already exists, the CREATE TABLE command simply has no effect (and no error message is returned). Now the table is created and its fine.
the way I have done it is create a seperate database, copy everything from the current one over to the temp new one then drop the old database do whatever there and then copy the information back from the temp database.
not sure if there is another way to do it but if there is I would love to hear about it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With