See https://www.sqlite.org/lang_altertable.html ... the ALTER TABLE
command, by default, now alters references to it in triggers/views.
To get the old behaviour, which I believe you need, use:

    PRAGMA legacy_alter_table=ON

Graham

Monday, April 01, 2019, 11:23:45 AM, Domingo Alvarez Duarte 
<mingo...@gmail.com> wrote:

> Hello !

> I'm using sqlite3 for a long time and I used to be able to drop tables 
> that have views without error before but now it seems that it is not 
> possible anymore.

> I mainly use it to restructure tables (add/move/remove fields) with 
> something like this:

> ====

> PRAGMA foreign_keys=OFF;

> BEGIN;

> CREATE TABLE "banks___new"(
>      id integer primary key,
>      account_id integer references ledger_accounts(id),
>      name varchar not null collate nocase unique,
>      new_field integer, -------------- for example here I'm adding a new 
> field
>      notes text collate nocase
> );

> INSERT INTO "banks___new"(
>      "id",
>      "account_id",
>      "name",
>      "notes"
>      )
> SELECT
>      "id",
>      "account_id",
>      "name",
>      "notes"
> FROM "banks";

> DROP TABLE "banks";

> ALTER TABLE "banks___new" RENAME TO "banks";

> PRAGMA foreign_key_check;

> COMMIT;

> PRAGMA foreign_keys=ON;



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to