Home  >  Article  >  Database  >  SQL Server中使用Linkserver连接Oracle的方法

SQL Server中使用Linkserver连接Oracle的方法

WBOY
WBOYOriginal
2016-06-07 18:07:021097browse

SQL Server提供了Linkserver来连接不同数据库上的同构或异构数据源。下面以图示介绍一下连接Oracle的方式

连接到Oracle的前提是在SQL Server服务器上安装Oracle Client。Oracle Client下载地址如下:

安装完毕后要修改对应的tnsnames文件才能连接对应的数据,该文件所在目录:

Oracle安装路径\product\10.2.0\client_1\NETWORK\ADMIN

连接字符串格式:

QAS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.181)(PORT = 1527))
)
(CONNECT_DATA =
(SERVICE_NAME = QAS)
)
)

首先打开SQL Server Management Studio, 展开到Server Objects-->Linked Server, 右键单击该项选择New linked Server输入Link Server的信息。

输入完成后显示信息如下:

SQL Server提供了两种方式连接Link Server:

select * from openquery(QAS, 'select * from sapr3.mseg')
select top 100 * from [QAS]..[SAPR3].[MSEG]

注意:

1)第二种方式需注意大小写
2)两种方式都不能使用索引,不支持大批量数据的使用

Statement:
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