select '1',decode(sum(v),0,1,0),'1','清理表完成','成功',sysdate
from (
select count(*) v from tm_f_subscrb_TEMP1
union all
select count(*) v from tm_f_subscrb_TEMP2
union all
select count(*) v from tm_f_subscrb);比如在上面的代码中union all起什么作用???
from (
select count(*) v from tm_f_subscrb_TEMP1
union all
select count(*) v from tm_f_subscrb_TEMP2
union all
select count(*) v from tm_f_subscrb);比如在上面的代码中union all起什么作用???
The following statement combines the results with the UNION operator, which eliminates duplicate selected rows. This statement shows that you must match datatype (using the TO_CHAR function) when columns do not exist in one or the other table:SELECT location_id, department_name "Department",
TO_CHAR(NULL) "Warehouse" FROM departments
UNION
SELECT location_id, TO_CHAR(NULL) "Department", warehouse_name
FROM warehouses;LOCATION_ID Department Warehouse
----------- --------------------- --------------------------
1400 IT
1400 Southlake, Texas
1500 Shipping
1500 San Francisco
1600 New Jersey
1700 Accounting
1700 Administration
1700 Benefits
1700 Construction
...UNION ALL Example
The UNION operator returns only distinct rows that appear in either result, while the UNION ALL operator returns all rows. The UNION ALL operator does not eliminate duplicate selected rows:SELECT product_id FROM order_items
UNION
SELECT product_id FROM inventories;SELECT location_id FROM locations
UNION ALL
SELECT location_id FROM departments;
A location_id value that appears multiple times in either or both queries (such as '1700') is returned only once by the UNION operator, but multiple times by the UNION ALL operator.结论:尽量使用union all,因为union需要进行排序,去除重复记录,效率低。
马上给分
不过看你给我的那些讲解真是费了很长时间啊
我英语不好啊呵呵
:)