Reputation: 37
i've been developing android app with my friend for my school project, and he did the database part, we using SQLite, and i wanna use the database scheme that he created, but the table are already defined, how can i somehow, rename the table and insert my own data in it without changing the scheme? we both use the same project folders so it kinda makes me stuck right now, thanks.
Upvotes: 1
Views: 511
Reputation: 10270
By using Alter Table:
ALTER TABLE oldTableName RENAME TO newTableName
Obviously replacing oldTableName
and newTableName
with whatever you choose. Then you can INSERT INTO
your table using the new name. Keep in mind that any references to this old table will also need to be updated.
Also take care if you're using any triggers:
Important Note: The
'ALTER TABLE ... RENAME TO ...'
command does not update action statements within triggers or SELECT statements within views. If the table being renamed is referenced from within triggers or views, then those triggers and views must be dropped and recreated separately by the application.
Upvotes: 2