Chinaunix首页 | 论坛 | 博客
  • 博客访问: 70717
  • 博文数量: 22
  • 博客积分: 300
  • 博客等级: 二等列兵
  • 技术积分: 167
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-03 22:28
文章分类

全部博文(22)

文章存档

2011年(22)

我的朋友

分类: Oracle

2011-11-21 11:03:18

  1. --查询相同的数据--

  2. SELECT *
  3.   FROM GL_VOUCHER
  4.  WHERE PK_VOUCHER IN (SELECT PK_VOUCHER
  5.                         FROM GL_VOUCHER
  6.                        GROUP BY PK_VOUCHER
  7.                       HAVING COUNT(PK_VOUCHER) > 1)

  8. --删除相同的数据--
  9. DELETE FROM GL_DETAIL
  10.  WHERE PK_DETAIL IN (SELECT PK_DETAIL
  11.                        FROM GL_DETAIL
  12.                       GROUP BY PK_DETAIL
  13.                      HAVING COUNT(PK_DETAIL) > 1)
  14.    AND ROWID NOT IN (SELECT MIN(ROWID)
  15.                        FROM GL_DETAIL
  16.                       GROUP BY PK_DETAIL
  17.                      HAVING COUNT(PK_DETAIL) > 1)


  18. --生成创建索引语句--

  19. SELECT 'create index ' || B.INDEX_NAME || ' on ' || B.TABLE_NAME || '(' || COL ||
  20.        ') tablespace ' || B.TABLESPACE_NAME || ';'
  21.   FROM (SELECT INDEX_NAME, WMSYS.WM_CONCAT(COLUMN_NAME) COL
  22.           FROM (SELECT INDEX_NAME, COLUMN_NAME
  23.                   FROM USER_IND_COLUMNS
  24.                  ORDER BY INDEX_NAME, COLUMN_POSITION)
  25.          GROUP BY INDEX_NAME) A,
  26.        USER_INDEXES B
  27.  WHERE A.INDEX_NAME = B.INDEX_NAME



  28. --查询Oracle隐含参数--

  29. SELECT X.KSPPINM NAME, Y.KSPPSTVL VALUE, X.KSPPDESC DESCRIB
  30.   FROM X$KSPPI X, X$KSPPCV Y
  31.  WHERE X.INST_ID = USERENV('Instance')
  32.    AND Y.INST_ID = USERENV('Instance')
  33.    AND X.INDX = Y.INDX
  34.    AND X.KSPPINM LIKE '%_db_block_hash%'
阅读(1635) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~