Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1185024
  • 博文数量: 398
  • 博客积分: 10110
  • 博客等级: 上将
  • 技术积分: 4055
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-23 20:01
个人简介

新博客http://www.cnblogs.com/zhjh256 欢迎访问

文章分类

全部博文(398)

文章存档

2012年(1)

2011年(41)

2010年(16)

2009年(98)

2008年(142)

2007年(100)

我的朋友

分类: Oracle

2007-12-25 13:43:38


-- Description  : Creates the DDL for the specified view.
-- Call Syntax  : @view_structure (view-name) (schema-name)
SET SERVEROUTPUT ON
SET VERIFY OFF
SET FEEDBACK OFF
PROMPT
DECLARE
    CURSOR cu_view IS
        SELECT *
        FROM   all_views a
        WHERE  a.view_name   = Upper('&&1')
        AND    a.owner       = Upper('&&2');
 
    CURSOR cu_tab_com IS
        SELECT a.table_name,
               a.comments
        FROM   all_tab_comments a
        WHERE  a.table_name = Upper('&&1')
        AND    a.owner      = Upper('&&2');
    CURSOR cu_col_com IS
        SELECT a.table_name,
               a.column_name,
               a.comments
        FROM   all_col_comments a
        WHERE  a.table_name = Upper('&&1')
        AND    a.owner      = Upper('&&2');
BEGIN
    DBMS_Output.Disable;
    DBMS_Output.Enable(1000000);
    FOR cur_view IN cu_view LOOP
        DBMS_Output.Put_Line('PROMPT');
        DBMS_Output.Put_Line('PROMPT Creating View ' || cur_view.view_name);
        DBMS_Output.Put_Line('CREATE OR REPLACE VIEW ' || Lower(cur_view.view_name) || ' AS');
        DBMS_Output.Put_Line(cur_view.text);
 DBMS_Output.Put_Line('/');
        DBMS_Output.Put_Line(' ');       
    END LOOP;
    FOR cur_tab_com IN cu_tab_com LOOP
        DBMS_Output.Put_Line('COMMENT ON TABLE ' || Lower(cur_tab_com.table_name) || ' IS ''' || cur_tab_com.comments || ''';');
    END LOOP;
    DBMS_Output.Put_Line(' ');
    FOR cur_col_com IN cu_col_com LOOP
        DBMS_Output.Put_Line('COMMENT ON COLUMN ' || Lower(cur_col_com.table_name || '.' || cur_col_com.column_name) || ' IS ''' || cur_col_com.comments || ''';');
    END LOOP;
    DBMS_Output.Put_Line(' ');
END;
/
SET VERIFY ON
SET FEEDBACK ON
阅读(888) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~