这不是使用 SA,而是一个示例来说明在 Sqlite3 中的两个表中插入行并且不进行往返。
创建一个连接两个表的视图,然后编写一个代替触发器来处理插入,然后插入到您的视图中。如果您想更进一步,修改 SA 以插入您的视图应该不难。
create table customer (id integer primary key autoincrement, name text not null);
create table address (id integer primary key autoincrement, customer_id integer references customer not null, street text);
create view customer_view as
select customer.id as customer_id, customer.name, address.id as address_id, address.street
from customer
inner join address on customer.id = address.id;
create trigger customer_view_insert_trg
instead of insert on customer_view begin
insert into customer (name) values (new.name);
insert into address (customer_id, street) values ((select last_insert_rowid()), new.street);
end;
insert into customer_view (name, street) values ('Joe', 'Main Street');
insert into customer_view (name, street) values ('Bill', 'Water Street');
sqlite> select * from customer;
1|Joe
2|Bill
sqlite> select * from address;
1|1|Main Street
2|2|Water Street