Home > Database > Mysql Tutorial > Oracle 创建数据连接

Oracle 创建数据连接

WBOY
Release: 2016-06-07 17:21:12
Original
1134 people have browsed it

1、为了建立数据库连接,需要有PCREATE Database link系统权限,要与远程的帐号进行连接还需要有CREATE session普通权限;2、保证

1、为了建立数据库连接,需要有PCREATE Database link系统权限,要与远程的帐号进行连接还需要有CREATE session普通权限;
2、保证连接的用户具有访问被连接数据库的表或者视图的权限。
3、在要创建连接的数据库 [TNSNAMES.ORA]文件添加对被连接数据库的连接字符。
LIMS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.126.6.14)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = LIMS)
)
)
或者用下面第二种创建连接方式。
3、建立数据库连接语法
CREATE [public] DATABASE LINK 数据库连接名
CONNECT TO 用户名 IDENTIFIED BY 密码
USING '数据库连接字符串';

CREATE DATABASE LINK "Oracle_13"
CONNECT TO "TOTALPLANT"
IDENTIFIED BY "********"
USING 'ORACLE_SERVER'
或者:
-- Create database link
create database link TOCCIC
  connect to ZTRY identified by ZTRY
  using '(DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = fengwenwei)(PORT = 1521))
  )
  (CONNECT_DATA =(SID = ZTRY))
  )';

4、一般情况PUBLIC由数据库管理员来创建;个人用户可以不加public,是私有的数据库连接;
5、在配置文件init.ora中,数据库参数global_name=true时,要求数据库连接名称跟远端数据库名称一样;数据库参数global_name=false时,数据库连接名称可以跟远端数据库名称不一样;重新启动数据库才生效,或者,修改上面的同时执行alter system set global_names=false不需要重新启动数据库;
6、在配置文件init.ora中,限制了数据库连接的数量,默认的并发数是4,由OP_LINKS来限制;
===============================
数据库全局名称可以用以下命令查出
SELECT * FROM GLOBAL_NAME;

查询远端数据库里的表
SELECT …… FROM 表名@数据库连接名;

查询数据库连接
select * from user_db_links;
删除数据库连接
DELETE USER_DB_LINKS;
DROP (PUBLIC) DATABASE LINK DBaseLinkToCompany

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template