创建一个视图,包括表A中存在但表B中不存在的数据
如
表A:
id
1
2
3
表B:
id
1
3
那么希望视图中是:
id
2
[解决办法]
- SQL code
select id from tb1exceptselect id from tb2
[解决办法]
- SQL code
create view [view_name]asselect a.idfrom 表A a left join 表B b on a.id=b.idwhere b.id is null
[解决办法]
- SQL code
create tigger test on afor deleteasbegindelete from b where exists(select 1 from instered where id=b.id)end
[解决办法]