[20180211]current_schema与dblink.txt

简介: [20180211]current_schema与dblink.txt --//有时候调优sql语句,经常在回话设在alter session set current_schema=scott,然后执行sql语句.

[20180211]current_schema与dblink.txt

--//有时候调优sql语句,经常在回话设在alter session set current_schema=scott,然后执行sql语句.
--//如果使用dblink是private,存在问题,做一个记录:

1.环境:

SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

CREATE PUBLIC DATABASE LINK LOOPBACK
CONNECT TO SCOTT
IDENTIFIED BY <PWD>
USING 'localhost:1521/book:DEDICATED';

CREATE DATABASE LINK LOOP
CONNECT TO SCOTT
IDENTIFIED BY <PWD>
USING 'localhost:1521/book:DEDICATED';

2.测试:
SYS@book> show user;
USER is "SYS"

SYS@book> alter session set current_schema=scott;
Session altered.

SYS@book> select * from dept@loopback ;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

SYS@book> select * from dept@loop ;
select * from dept@loop
                   *
ERROR at line 1:
ORA-02019: connection description for remote database not found

$ oerr ora 2019
02019, 00000, "connection description for remote database not found"
// *Cause:
// *Action:

--//使用alter session时,私有的DBLINK依然不能使用,必须使用public DBLINK.如何使用呢?

目录
相关文章
|
7月前
|
SQL 监控 NoSQL
db.oplog.rs.find({"ns": "your_database_name.your_collection_name", "o": {$exists: true}}).sort({$natural: -1}).limit(1) 这个SQL什么意思
【6月更文挑战第29天】db.oplog.rs.find({"ns": "your_database_name.your_collection_name", "o": {$exists: true}}).sort({$natural: -1}).limit(1) 这个SQL什么意思
63 8
|
SQL 存储 关系型数据库
MySQL中count(*)和information_schema.tables中的table_rows值不相同
MySQL中count(*)和information_schema.tables中的table_rows值不相同
446 0
|
关系型数据库 MySQL 容器
连接mysql报错Table ‘performance_schema.session_variables’
常规的方法是运行mysql时,提示Table ‘performance_schema.session_variables’ doesn’t exist解决的方法是:第一步:在管理员命令中输入: mysql_upgrade -u root -p --force 第二步:重新启动mysql的服务: n...
6505 0
|
SQL 关系型数据库 MySQL
Mysql - You can't specify target table '表名' for update in FROM clause 错误解决办法
Mysql - You can't specify target table '表名' for update in FROM clause 错误解决办法
369 0
Mysql - You can't specify target table '表名' for update in FROM clause 错误解决办法
|
C++
[odb-users] Create schema error (unknown database schema &#39;&#39;)
Boris Kolpackov boris at codesynthesis.com Fri May 31 11:13:02 EDT 2013   Previous message: [odb-users] Create schema error (unknown database schem...
1453 0