SQLite Forum

ALTER TABLE new_X RENAME TO X issue.
Login
Hi, I am following these steps in https://sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes 

to make some schema changes, but looks like there's some issue with it, I'm wondering if it's a designed feature or if it's a routine that could be improved.

To make the reproduce steps simple, consider a database has this schema, that is two tables "Test", "New_Test", and a view "TestView":

`
CREATE TABLE Test (
    id INTEGER PRIMARY KEY
)
;
`
`
CREATE TABLE New_Test (
    id INTEGER PRIMARY KEY
)
;
`
`
CREATE VIEW TestView AS
SELECT
    Test.id
FROM Test
;
`

Then if I do 

`
DROP TABLE Test;
ALTER TABLE New_Test RENAME TO Test;
`

I will get an error: 

`error in view TestView: no such table: main.Test`

I mean of course there's no such table "main.Test", because I dropped it, and I want another table to be the "main.Test".

I know that if I drop the view "TestView" before the "ALTER TABLE..." step, then recreate the view after the "ALTER TABLE..." step will work, but it just feel weird.

So like I mentioned before, is this a designed feature or is this a routine that could be improved?