zoukankan      html  css  js  c++  java
  • gen_create_syn.sql

    set echo off feedback off verify off pagesize 0 linesize 120

     ---变量从 sqlplus 的 call代码 传递过来 。

    -- 1 表示连接用户

    -- 2表示连接用户密码

    -- 3表示连接字符串

    ---4表示授权用户

    define v_input_un         = &1 
    define v_input_pw         = &2
    define v_input_conn_str   = &3
    define v_input_owner      = &4

    connect &v_input_un/&v_input_pw@&v_input_conn_str

    define v_create_syn_command_file = .logcreate_syn_&v_input_un._&v_input_owner..sql
    define v_create_syn_log_file     = .logcreate_syn_&v_input_un._&v_input_owner..log

     -- not exists 就是判断语句,如果没有子条件数据返回,就继续查询。

    spool &v_create_syn_command_file.
    prompt spool &v_create_syn_log_file.
    prompt set echo on feedback on
    prompt show user
    select
      'create or replace synonym '|| o.object_name ||' for &v_input_owner..'||o.object_name||';'
    from     all_objects o
    where    o.owner =  upper('&v_input_owner')
    and      user    != upper('&v_input_owner')
    and      o.object_type in ('TABLE', 'VIEW', 'SEQUENCE', 'PACKAGE', 'PROCEDURE', 'FUNCTION')
    and      not exists
      (select null
       from   user_synonyms s
       where  s.table_owner = o.owner
       and    s.table_name  = o.object_name)
    order by o.object_name
    /
    select
      'create or replace synonym '|| a_s.synonym_name ||' for &v_input_owner..'||a_s.synonym_name||';'
    from     all_synonyms a_s
    where    a_s.owner =  upper('&v_input_owner')
    and      user      != upper('&v_input_owner')
    and      not exists
      (select null
       from   user_synonyms u_s
       where  u_s.table_owner = a_s.owner
       and    u_s.table_name  = a_s.synonym_name)
    order by a_s.synonym_name
    /
    prompt spool off
    spool off

    @&v_create_syn_command_file.

  • 相关阅读:
    [原译]关于源代码控制的五个误区
    [原译]AVALONDOCK 2.0入门指南第一部分
    [原译]11个高效的VS调试技巧
    【原译】一个可定制的WPF任务对话框
    [原译]YAXLib XML序列化神器
    为什么SIZEOF(STR.SUBSTR(0,3).C_STR())=8?
    C#实现GIF图片反转
    转 基于jquery ajax 用户无刷新登录详解介绍
    php中判断文件空目录是否有读写权限
    防止mysql用户root密码弱口令的攻击方法
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/5897016.html
Copyright © 2011-2022 走看看