Thinking off the cuff, there'd be a seven step process for this; Begin Transaction Turn off the PK/FK relationship PRAGMA constraint checks Rename old table to a temp table via whatever means are available Create the new table INSERT INTO the new table Turn on the PK/FK relationship PRAGMA constraint check End transaction.
I've never manually run the SQLite commands to perform a rename, as I use SQLite expert, and "F2" allows me to rename if needed (So it does all the legwork) so I don't know if its an alter table command or you have to go the drop/create route. On top of that, my databases typically only contain about a meg or two of textual data, so, how quick my F2 would work on a larger dataset, I don't know. SQLite does not hold a unique permanent "link" from one table to another. So the act of renaming, and then re-provisioning the table will not change your code or how the other tables view the new table. Its concern is that at the time of the SQL execution, the tables and fields exist as required. In other words, if you do rename a table, every other table in the database is oblivious to the change, meaning its not aware. On Tue, May 22, 2018 at 3:34 PM, Igor Korot <[email protected]> wrote: > Hi, Charles, > > On Tue, May 22, 2018 at 2:30 PM, Charles Leifer <[email protected]> > wrote: > > As a workaround, you can always rename the existing table, create the new > > table with desired attributes, and do a INSERT INTO ... SELECT FROM > > old_table. Then you can safely drop the old table. > > But the table_name will be different. > Also the data in the old table might be referencing some other table. > So this process is not really very > straightforward... > > Thank you. > > > > > On Tue, May 22, 2018 at 1:14 PM, Thomas Kurz <[email protected]> > wrote: > > > >> > ALTER TABLE ADD COLUMN has existed for a long time. > >> > >> Yes, sorry, I mixed things up. > >> > >> The order of importance is imho: > >> 1. RENAME COLUMN (shouldn't be too hard) > >> 2. DROP COLUMN (should be a bit more comlicated but feasible) > >> 3. MODIFY COLUMN > >> > >> > What kind of MODIFY COLUMN changes do you have in mind? > >> > >> I understand this can be difficult as there are many possible operations > >> that might be incompatible with the data already stored in that column. > >> Last time I needed MODIFY, I wanted to change the ON UPDATE/DELETE > CASCADE > >> action of a foreign key column. Also adding/removing a foreign key > would be > >> useful. > >> > >> Kind regards, > >> Thomas > >> > >> _______________________________________________ > >> sqlite-users mailing list > >> [email protected] > >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > >> > > _______________________________________________ > > sqlite-users mailing list > > [email protected] > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > [email protected] > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

