The question basically says it. I want the last four columns of a table to use the data entered in the first three to assign a default value on a row insert (a concatenation of 4 columns) . Is this possible?
这可以通过在插入后直接更新记录的触发器来实现:
CREATE TRIGGER MyTable_col4_default_value
AFTER INSERT ON MyTable
FOR EACH ROW
WHEN NEW.col4 IS NULL
BEGIN
UPDATE MyTable
SET col4 = NEW.col1 || NEW.col2 || NEW.col3
WHERE rowid = NEW.rowid;
END;