5 ms·
It is. It is a bunch of complex commands. Just look at the proposed solutions on Stackoverflow: https://stackoverflow.com/questions/8442147/how-to-delete-or-ad
by FreeHugs 7y ago
It is. It is a bunch of complex commands. Just look at the proposed solutions on Stackoverflow:
https://stackoverflow.com/questions/8442147/how-to-delete-or-add-column-in-sqlite https://stackoverflow.com/questions/8442147/how-to-delete-or...
- Dowwie 7y agoSo I'll keep my opinion about this out of this response. To those who are interested, the approved answer on that SO thread recommends: 1. create new table as the one you are trying to change 2. copy all data, 3. drop old table, 4. rename the new one. It's up to others to decide whether that is complex enough to warrant avoiding sqlite
- Someone 7y agoThat gets more cumbersome if the table has indexes (you will have to create them on the new table), and even more cumbersome if foreign keys point to it (you will have to drop them before step 3 and recreate them after step 4) “Copy all data” also can be difficult if the table has data that the database created that must stay the same because you use it elsewhere. That shouldn’t be a problem with SQLite, as it doesn’t allow rowid as foreign key, but if you use it as a foreign key outside the database, or use the hash of a full row to detect changes, it may still bite you. It also may mean being offline for a significant amount of time, but that also often is (effectively) the case for databases that support deleting columns
- Dowwie 7y agogood points
- bfrog 7y agoWhich adds up to dozens to hundreds of lines of code which needs to be maintained in each project you use sqlite with, vs the one liner of sql that would be required if using a sql that supported it.
- mbreese 7y agoIt's only required if you need the ability to change the schema of a SQLite table at runtime. I'd wager that's not a very common use-case for SQLite.
- tylerhou 7y agoWhat about database migrations? My app which uses a SQLite database needs to store an additional column for a table. Now I have to write a bunch of custom code to migrate it.