gpt4 book ai didi

database - Oracle 创建数据库链接

转载 作者:行者123 更新时间:2023-12-02 17:22:42 24 4
gpt4 key购买 nike

我使用的是 Oracle 11g 快捷版。我已经创建了表、存储过程并且工作正常。我的用户“系统”和密码“xyz”(安装期间的主要用户)。

然后我用同一个用户创建了两个数据库“abc”和“pqr”。

我想创建从 abc 到 pqr 的数据库链接。

create database link testlink
connect to pqr identified by xyz
using '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)) (CONNECT_DATA=(sid=xe)))';

我收到错误“权限不足”。请帮帮我。

最佳答案

它应该是 CONNECT TO 用户名而不是数据库名称,如下图所示,它描述了 CREATE DATABASE LINK 的语法。我们在 USING connect_string 子句下定义数据库实例/服务。

enter image description here

Prerequisites

To create a private database link, you must have the CREATE DATABASE LINK system privilege. To create a public database link, you must have the CREATE PUBLIC DATABASE LINK system privilege. Also, you must have the CREATE SESSION system privilege on the remote Oracle database.

引用: CREATE DATABASE LINK

演示

[oracle@orcl Desktop]$ sqlplus system/oracle

SQL> create user abc identified by abc;

User created.

SQL> create user xyz identified by xyz;

User created.

SQL> grant create session to abc;

Grant succeeded.

SQL> conn abc/abc
Connected.

SQL> create database link testlink connect to pqr identified by pqr using '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.dba.com)(PORT=1522)) (CONNECT_DATA=(service=orcl)))';
create database link testlink connect to pqr identified by pqr using '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.dba.com)(PORT=1522)) (CONNECT_DATA=(service=orcl)))'
*
ERROR at line 1:
ORA-01031: insufficient privileges


SQL> conn system/oracle
Connected.
SQL> grant create database link to abc;

Grant succeeded.

SQL> create database link testlink connect to pqr identified by pqr using '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.dba.com)(PORT=1522)) (CONNECT_DATA=(service=orcl)))';^[[3~^C

SQL> conn abc/abc
Connected.
SQL> create database link testlink connect to pqr identified by pqr using '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.dba.com)(PORT=1522)) (CONNECT_DATA=(service=orcl)))';

Database link created.

关于database - Oracle 创建数据库链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41477825/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com