SQLite Forum

Apparent bug in ALTER TABLE
Login
If a view exists on a table which does not exist, and PRAGMA LEGACY_ALTER_TABLE is currently 0, and an attempt is made to rename another table to be the one which the view refers to, sqlite reports an error.

To reproduce, run this sequence of SQL statements:-  
`CREATE TABLE main (column1, column2) ;
CREATE VIEW sorted AS SELECT * FROM main ORDER BY column1 ;
PRAGMA LEGACY_ALTER_TABLE = 1 ;
ALTER TABLE main RENAME TO other ;
PRAGMA LEGACY_ALTER_TABLE = 0 ;
ALTER TABLE other RENAME TO main ;`

The last statement reports
Error: error in view sorted: no such table: main.main Unable to fetch row.

IMHO there is  no error here: the statement is attempting to *create* the missing table, not to remove it.

Found using Sqlite: 3.28.0  
Script run using github.com/rparkins999/sqliteman  
OS: openSUSE Leap 15.1 Linux 4.12.14-lp151.28.87-default