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 = .\log\create_syn_&v_input_un._&v_input_owner..sql
define v_create_syn_log_file = .\log\create_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.
gen_create_syn.sql的更多相关文章
- call_create_syn.sql
promptprompt ================================================================================prompt ...
- 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目
最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...
- SQL Server 大数据搬迁之文件组备份还原实战
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...
- Sql Server系列:分区表操作
1. 分区表简介 分区表在逻辑上是一个表,而物理上是多个表.从用户角度来看,分区表和普通表是一样的.使用分区表的主要目的是为改善大型表以及具有多个访问模式的表的可伸缩性和可管理性. 分区表是把数据按设 ...
- SQL Server中的高可用性(2)----文件与文件组
在谈到SQL Server的高可用性之前,我们首先要谈一谈单实例的高可用性.在单实例的高可用性中,不可忽略的就是文件和文件组的高可用性.SQL Server允许在某些文件损坏或离线的情况下,允 ...
- EntityFramework Core Raw SQL
前言 本节我们来讲讲EF Core中的原始查询,目前在项目中对于简单的查询直接通过EF就可以解决,但是涉及到多表查询时为了一步到位就采用了原始查询的方式进行.下面我们一起来看看. EntityFram ...
- 从0开始搭建SQL Server AlwaysOn 第一篇(配置域控)
从0开始搭建SQL Server AlwaysOn 第一篇(配置域控) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www.cnb ...
- 从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群)
从0开始搭建SQL Server AlwaysOn 第二篇(配置故障转移集群) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www ...
- 从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn)
从0开始搭建SQL Server AlwaysOn 第三篇(配置AlwaysOn) 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://w ...
随机推荐
- javascript中函数的call,apply及bind方法
call 方法调用一个对象的一个方法,以另一个对象替换当前对象.call([thisObj[,arg1[, arg2[, [,.argN]]]]])参数thisObj可选项.将被用作当前对象的对象. ...
- VBS基础篇 - 对象(1) - Class对象
VBS基础篇 - 对象(1) - Class对象 相信对JAVA有一定了解的朋友一定对类这个名词不陌生,但是大家可能没有想过在VBS中使用Class类吧,其实Class类在自动化测试中是相当常用的 ...
- JavaScript在智能手机上的应用-判断是否为移动浏览器
-------------------- <script type="text/javascript"> var userAgent = navi ...
- HTTP Keep-Alive详解[转]
HTTP是一个请求<->响应模式的典型范例,即客户端向服务器发送一个请求信息,服务器来响应这个信息.在老的HTTP版本中,每个请求都将被创建一个新的客户端->服务器的连接,在这个连接 ...
- ebtables
ebtables是以太网桥防火墙,以太网工作在数据链路层,ebtables过滤数据链路层包.2.6内核内置了ebtables,要使用它必须先按装她的用户空间工具(ebtables-V2.0.6),安装 ...
- 利用proxychains在终端使用socks5代理
最近用各种脚本下载东西的时候发现有的站点需要当地IP才能下,比如.....nico, youtube等: 所以就找了下能在终端用socks5代理的工具,最后找到了proxychains,从此再无压力= ...
- MyBatis-配置缓存
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"> <property name="tim ...
- Openlays 3 绘制基本图形
<body> <div id="menu"> <label>几何图形类型:</label> <select id=" ...
- Hibernate 系列教程17-查询缓存
在二级缓存配置成功的基础上进行查询缓存配置 Product public class Product { private Long id; private String name; Product.h ...
- Flask architecture
论文The Flask Security Architecture: System Support for Diverse Security Policies 介绍了Flask architectur ...