ITPub博客

首页 > 数据库 > Oracle > DBMS_Utility学习

DBMS_Utility学习

原创 Oracle 作者:chncaesar 时间:2013-12-04 14:46:40 0 删除 编辑
Comma_to_table  和 Table_to_Comma,比较有用。以下是例子:
DECLARE
  v_len BINARY_INTEGER;
  v_tab DBMS_UTILITY.UNCL_ARRAY;
  v_idx BINARY_INTEGER;
  v_str VARCHAR2(200);  
BEGIN
  DBMS_UTILITY.COMMA_TO_TABLE (
    'a,b,c',  --每个元素必须符合Oracle命名规约,即:不能以数字开头
    v_len,
    v_tab);
  
   v_idx := v_tab.FIRST;
   WHILE(v_idx IS NOT NULL) LOOP
      dbms_output.put_line(v_tab(v_idx));
      v_idx := v_tab.NEXT(v_idx);
   END LOOP;
   
   dbms_utility.Table_to_Comma(v_tab, v_len, v_str);
   dbms_output.put_line(v_str);
END;

a
b
c

a,b,c

取得数据库各对象之间依赖关系 - dbms_utility.GET_DEPENDENCY
CREATE VIEW SAL_SUMMARY_BY_DEPT AS SELECT DEPTNO, SUM(SAL) SAL FROM emp GROUP BY DEPTNO;
EXEC dbms_utility.GET_DEPENDENCY('TABLE','SCOTT','EMP');
DEPENDENCIES ON SCOTT.EMP
------------------------------------------------------------------
*TABLE SCOTT.EMP()
*   VIEW SCOTT.SAL_SUMMARY_BY_DEPT()
也可以实用User_Dependencies(dba_dependencies, all_dependencies)来获取依赖关系
SELECT * FROM user_dependencies WHERE REFERENCED_NAME = 'EMP';

计算哈希值 - dbms_utility_get_hash_value
To get a hash value on a string where the hash value should be between 1000 and 3047, use 1000 as the base value and 2048 as the hash_size value. 
Using a power of 2 for the hash_size parameter works best.

SELECT DBMS_UTILITY.GET_HASH_VALUE('A', 0,2048) hash_value FROM dual;


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/638844/viewspace-1062165/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-07-30

  • 博文量
    102
  • 访问量
    900162