标签:技术 strong int where 计算公式 计算 color 字段 style
oracle中有三种集合操作,他们会把左边和右边的select 结果集进行集合操作.
create table STUDENT_A ( id VARCHAR2(36) not null, name VARCHAR2(100), age NUMBER, sex VARCHAR2(2) ); insert into STUDENT_A (id, name, age, sex) values (‘1‘, ‘bobo‘, 28, ‘1‘); insert into STUDENT_A (id, name, age, sex) values (‘2‘, ‘sisi‘, 29, ‘2‘); commit; create table STUDENT_B ( id VARCHAR2(36) not null, name VARCHAR2(100), age NUMBER, clazz VARCHAR2(36) ); insert into STUDENT_B (id, name, age, clazz) values (‘1‘, ‘bobo‘, 28, ‘1‘); insert into STUDENT_B (id, name, age, clazz) values (‘2‘, ‘sisi‘, 29, ‘2‘); insert into STUDENT_B (id, name, age, clazz) values (‘3‘, ‘kiki‘, 30, ‘1‘); commit;
注意下面的小括号不能省,因为是从左到右计算的,如果省掉计算公式就不一样了哦,大家可以自行脑补.
( SELECT column_name FROM user_tab_columns WHERE table_name = ‘STUDENT_A‘ MINUS SELECT COLUMN_name FROM user_tab_columns WHERE table_name = ‘STUDENT_B‘ ) UNION ( SELECT column_name FROM user_tab_columns WHERE table_name = ‘STUDENT_B‘ MINUS SELECT COLUMN_name FROM user_tab_columns WHERE table_name = ‘STUDENT_A‘ )
注意下面的小括号不能省,因为是从左到右计算的,如果省掉计算公式就不一样了哦,大家可以自行脑补.
( SELECT * FROM STUDENT_A MINUS SELECT * FROM STUDENT_B ) UNION ( SELECT * FROM STUDENT_B MINUS SELECT * FROM STUDENT_A )
同上图可知比较内容的时候,是不关心字段名是否有差异的,它只关心字段的类型和值.
标签:技术 strong int where 计算公式 计算 color 字段 style
原文地址:http://www.cnblogs.com/whatlonelytear/p/6092779.html