假设有两张表A和B,A表有两个字段:Key_A和Value_A;B表有两个字段:Key_B和Value_B。各用一个SQL语句实现如下功能:
1从A和B中查询出A.Key_A=B.Key_B的所有记录;
2将B表中的记录全部插入A表;insert into A select * from B
3查询出A表中存在而B表中不存在的记录;
4查询出A表和B表中完全相同的记录(A.Key_A=B.Key_B and A.Value_A=B.Value_B);
5当A.Key_A=B.Key_B时,将A表的Value_A字段更新为的B表Value_B字段;
1从A和B中查询出A.Key_A=B.Key_B的所有记录;
2将B表中的记录全部插入A表;insert into A select * from B
3查询出A表中存在而B表中不存在的记录;
4查询出A表和B表中完全相同的记录(A.Key_A=B.Key_B and A.Value_A=B.Value_B);
5当A.Key_A=B.Key_B时,将A表的Value_A字段更新为的B表Value_B字段;
解决方案 »
- 请教高手:ORACLE关于行列转换中某一列的数据既要作为行也要作为列的问题!
- 急啊!oracle中如何查第几个星期的内容??在线等。谢谢了。
- 动态创建表和索引
- oracle报错 ORA-00933: SQL command not properly ended
- 编写存储过程的步骤和语法是怎样的,它是怎样执行的,请高手光临指导!
- 请教Oracle和Sybase建库的速度比较,100分解决即结贴
- Linux 的sqlplus如何设置才能看到表中的中文字段?
- 请教一个xmltype数据存储的问题
- 在liunx9下安装ora817出现的问题
- 在red hat 8 个人版能安装oracle 8 或9吗
- 请教update的顺序和原理
- 服务器 为什么不先用那闲着的 34% /dev/shm内存?
select * from a,b where a.key_a = b.key_b;
2
insert into a select * from b;
3
select * from a where not exists(select 1 from b where b.key_b = a.key_a and b.value_b = a.value_a);
4
select * from a,b where a.key_a=b.key_b and a.value_a=b.value_b;
5
update a set value_a = (select value_b from b where b.key_b = a.key_a) where exists(select 1 from b where b.key_b = a.key_a);
select * from a,b where a.key_a = b.key_b;
2
insert into a select * from b;
3
select * from a where not exists(select 1 from b where b.key_b = a.key_a and b.value_b = a.value_a);
4
select * from a,b where a.key_a=b.key_b and a.value_a=b.value_b;
5
update a set value_a = (select value_b from b where b.key_b = a.key_a) where exists(select 1 from b where b.key_b = a.key_a);