科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网安全频道Oracle数据库11g:SQL计划管理(二)

Oracle数据库11g:SQL计划管理(二)

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

本文—该系列文章的第二篇—解释在升级一个现存的Oracle10gR2数据库到Oracle11g时如何使用SQL计划管理,与部署新应用程序代码一样,有效地限制SQL语句性能异常回退。

作者:Jim Czuprynski/黄永兵 译 来源:51CTO.com    2008年7月7日

关键字: ORACLE SQL 数据库安全

  • 评论
  • 分享微博
  • 分享邮件

在本页阅读全文(共3页)

 

  FROM

  sh.sales SH

  ,sh.customers C

  ,sh.countries T

  WHERE SH.cust_id = C.cust_id

  AND C.country_id = T.country_id

  AND T.country_iso_code IN ('GB','PL')

  GROUP BY C.cust_state_province

  -----

  -- Query: SPM_2.2.2

  -- Purpose: Show distribution of geographic areas within

  -- Sales Region and District

  -----

  SELECT /*SPM_2.2.2*/

  SR.abbr,

  SD.abbr,

  SZ.geo_id,

  COUNT(C.cust_id) "Count"

  FROM

  sfa.sales_regions SR,

  sfa.sales_districts SD,

  sfa.sales_zones SZ,

  sh.customers C

  WHERE SD.region_id = SR.region_id

  AND SZ.district_id = SD.district_id

  AND C.cust_state_province = SZ.geo_id

  AND SR.abbr = 'SE00'

  GROUP BY

  SR.abbr

  ,SD.abbr

  ,SZ.geo_id

  -----

  -- Query: SPM_2.2.3

  -- Purpose: Accumulate quantities and revenue within Sales Region, District,

  -- and Territory. Note that this query +should+ take advantage of

  -- materialized view SFA.MV_SALES_SUMMARY for most effective retrieval

  -----

  SELECT /*SPM_2_2.3*/

  SR.abbr

  ,SD.abbr

  ,SZ.geo_id

  ,C.cust_id

  ,SUM(SH.quantity_sold)

  ,AVG(SH.quantity_sold)

  ,COUNT(SH.quantity_sold)

  ,SUM(SH.amount_sold)

  ,AVG(SH.amount_sold)

  ,COUNT(SH.amount_sold)

  FROM

  sfa.sales_regions SR

  ,sfa.sales_districts SD

  ,sfa.sales_zones SZ

  ,sh.customers C

  ,sh.sales SH

  WHERE SD.region_id = SR.region_id

  AND SZ.district_id = SD.district_id

  AND C.cust_state_province = SZ.geo_id

  AND C.cust_ID = SH.cust_id

  GROUP BY

  SR.abbr

  ,SD.abbr

  ,SZ.geo_id

  ,C.cust_id

  ORDER BY

  SR.abbr

  ,SD.abbr

  ,SZ.geo_id

  ,C.cust_id

  -----

  -- Query: SPM_2.2.4

  -- Purpose: Accumulate quantities and revenue within Sales Region, District,

  -- and Territory by querying directly against SFA.MV_SALES_SUMMARY

  -----

  SELECT /*SPM_2_2.4*/

  rgn_abbr

  ,dst_abbr

  ,ter_abbr

  ,cust_id

  ,tot_qty_sold

  ,avg_qty_sold

  ,cnt_qty_sold

  ,tot_amt_sold

  ,avg_amt_sold

  ,cnt_amt_sold

  FROM

  sfa.mv_sales_summary

  WHERE dst_abbr = 'NE20'

  ORDER BY

  rgn_abbr

  ,dst_abbr

  ,ter_abbr

  ,cust_id

  -----

  -- Query: SPM_2.2.5

  -- Purpose: Accumulate quantities and revenue within Sales Region and District.

  -- for a selected Region. Note that this query +should+ take advantage

  -- of materialized view SFA.MV_SALES_SUMMARY for most effective retrieval

  -----

  SELECT /*SPM_2_2.5*/

  SR.abbr

  ,SD.abbr

  ,SUM(SH.quantity_sold)

  ,AVG(SH.quantity_sold)

  ,COUNT(SH.quantity_sold)

  ,SUM(SH.amount_sold)

  ,AVG(SH.amount_sold)

  ,COUNT(SH.amount_sold)

  FROM

  sfa.sales_regions SR

  ,sfa.sales_districts SD

  ,sfa.sales_zones SZ

  ,sh.customers C

  ,sh.sales SH

  WHERE SD.region_id = SR.region_id

  AND SZ.district_id = SD.district_id

  AND C.cust_state_province = SZ.geo_id

  AND C.cust_ID = SH.cust_id

  AND SR.abbr = :rgn_abbr

  GROUP BY

  SR.abbr

  ,SD.abbr

  ORDER BY

  SR.abbr

  ,SD.abbr

  -----

  -- Query: SPM_2.2.6

  -- Purpose: Accumulate quantities and revenue within Sales Region. Note that

  -- this query +cannot+ take advantage of SFA.MV_SALES_SUMMARY for

  -- effective retrieval because of the selection criteria against

  -- Region Description

  -----

  SELECT /*SPM_2_2.6*/

  SR.abbr

  ,SUM(SH.quantity_sold)

  ,AVG(SH.quantity_sold)

  ,COUNT(SH.quantity_sold)

  ,SUM(SH.amount_sold)

  ,AVG(SH.amount_sold)

  ,COUNT(SH.amount_sold)

  FROM

  sfa.sales_regions SR

  ,sfa.sales_districts SD

  ,sfa.sales_zones SZ

  ,sh.customers C

  ,sh.sales SH

  WHERE SD.region_id = SR.region_id

  AND SZ.district_id = SD.district_id

  AND C.cust_state_province = SZ.geo_id

  AND C.cust_ID = SH.cust_id

  AND C.cust_id = :cust_id

  AND SR.description LIKE :rgn_desc

  GROUP BY

  SR.abbr

  ORDER BY

  SR.abbr

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章