oracle9i和oracle8i都可以在DBA用户下用SQL命令改变global_names参数
alter system set global_names=false; |
建立公有的数据库链接:
create public database link pubs
connect to testuser identified by testuser_pwd using "pubs";
create public database link northwind
connect to testuser identified by testuser_pwd using "northwind";
(假设SQL Server下pubs和northwind已有足够权限的用户登陆testuser,密码为testuser_pwd) |
访问SQL Server下数据库里的数据:
select * from stores@pubs;
...... ......select *
from region@northwind;
...... ...... |
3、使用时的注意事项
ORACLE通过访问SQL Server的数据库链接时,用select * 的时候字段名是用双引号引起来的。
例如:
create table stores as select * from stores@pubs;
select zip from stores;
ERROR 位于第 1 行:
ORA-00904: 无效列名
select "zip" from stores;
zip
-----
98056
92789
96745
98014
90019
89076 |
已选择6行,用SQL Navigator或Toad看从SQL Server转移到ORACLE里的表的建表语句为:
CREATE TABLE stores
("stor_id" CHAR(4) NOT NULL,
"stor_name" VARCHAR2(40),
"stor_address" VARCHAR2(40),
"city" VARCHAR2(20),
"state" CHAR(2),
"zip" CHAR(5))
PCTFREE 10
PCTUSED 40
INITRANS 1
MAXTRANS 255
TABLESPACE users
STORAGE (
INITIAL 131072
NEXT 131072
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS 2147483645
)
/ |
总结:
Windows下Oracle9i网关服务器在$Oracle9i_HOME g4mSQLadmin目录下的initSQLserver_databaseid.ora。Windows下Oracle9i网关服务器listener.ora里面:
(SID_DESC=
(SID_NAME=SQLserver_databaseid)
(ORACLE_HOME=d:OracleOra92)
(PROGRAM=tg4mSQL)
)
Unix或WINDOWS下ORACLE8I,ORACLE9I服务器tnsnames.ora里面
northwind =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))
)
(CONNECT_DATA =
(SID = SQLserver_databaseid)
)
(HS = SQLserver_databaseid)
) |
需要SQLserver_databaseid一致才行。