Edit Read Only View

I have a column, and I would like to edit some of its rows. The problem is that the table is a view, so I cannot edit rows. How can I proceed to solve this problem?

+5
source share
4 answers

SQLite does not allow updating views. But this allows triggers in the views. Thus, you can write a trigger INSTEAD OF UPDATEthat makes the appropriate changes to the base table.

+3
source

dan04, ( ). sqlite . http://www.sqlite.org/lang_createtrigger.html#instead_of_trigger

"myview", "my_t2"

CREATE TRIGGER myview_update INSTEAD OF UPDATE ON myview
BEGIN
  UPDATE my_t2 SET field1 = new.field1, field2 = new.field2 WHERE my_t2.key = old.key;
END
+3

, . . , , .

+2

SQL View - , SQL SELECT. , ( , ), , , - . , . . , , , .

If you want to change the data in your table, you cannot do this with a view. SQL views are always read-only. If you want to modify the table outside of the view, use something like an UPDATEor statement ALTER TABLE.

0
source

All Articles