1

我有两张表说 tab_1 和 tab_2。现在,每当我在 tab_1 上编写插入命令时,数据也应该插入到 tab_2 中。我怎样才能实现这个功能?

4

3 回答 3

2

您可以使用多表INSERT 语句

insert all
  into table1 (col1, col2, col4)
   values (col1, col2, col4)
  into table2 (col1, col2, col3, col4)
   values (col1, col2, col3, col4)
select col1, col2, col3, col4
  from some_other_table
于 2013-09-03T14:24:24.047 回答
0

I like things simple. I believe in true MVC and would add the save to the second table in the model and call the model each time I save anything in the data layer.

In the model save to the first table then to the second table if first was successful. That is how I save to my local device and to the api server. Works well and have not had any issues.

于 2013-09-04T00:23:49.033 回答
0

要删除的触发器应如下所示:

create or replace trigger <trigger_name>
after delete on table1 for each row
declare
begin
delete from table2 where key_column = :old.key_column
end;

:old.key_column 将是当前从 table1 中删除的行的键值。

于 2013-09-04T14:27:51.523 回答