本地数据库中必须创建了远程数据库的dblink,通过dblink本地数据库可以像访问本地数据库一样访问远程数据库表中的数据。具体命令如下:
--查询当前数据库有多少dblink连接
select * from ALL_DB_LINKS;
--创建dblink连接 ( to_db )dblink名 (test)账号 (1234)密码 (192.168.1.100/ORCL)数据库实例名 用户名和密码必须是双引号("")
create public database link to_db connect to "test" identified by "1234" using '192.168.1.100/ORCL';
--查询to_db数据库的t_test表
select * from t_test@to_db
--删除dblink
drop public database link to_db;