先说应用(*******代表密码),创建dblink如下sql:
create public database link dblink91_gps connect to ehl_gps identified by ****** using '10.2.111.91:1521/orcl'
create public database link dblink91_public connect to ehl_public identified by ****** using '10.2.111.91:1521/orcl'
create public database link dblink91_public connect to ehl_public identified by ****** using '10.2.111.91:1521/orcl'
创建使用视图如下(select * from table_name@dblink_name):
create or REPLACE view v_service_person
AS
select syjy as policeid,
(select p.xm from t_sys_person@dblink91_public p where p.ryid = pda.syjy) as policename,
pda.gljg as deptid,
(select d.jgmc from t_sys_department d where d.jgid = pda.gljg) as deptname,
r.gpstime as datetime,
r.longtitude,
r.latitude,
r.gpstime,
to_char(sysdate, 'yyyy/mm/dd hh24:mi:ss') as addtime
from t_in_oms_pda@dblink91_public pda, t_in_pgps_locateinfo@dblink91_gps r
where r.deviceid = pda.dwsbbh
AS
select syjy as policeid,
(select p.xm from t_sys_person@dblink91_public p where p.ryid = pda.syjy) as policename,
pda.gljg as deptid,
(select d.jgmc from t_sys_department d where d.jgid = pda.gljg) as deptname,
r.gpstime as datetime,
r.longtitude,
r.latitude,
r.gpstime,
to_char(sysdate, 'yyyy/mm/dd hh24:mi:ss') as addtime
from t_in_oms_pda@dblink91_public pda, t_in_pgps_locateinfo@dblink91_gps r
where r.deviceid = pda.dwsbbh
Oracle创建、删除DATABASE LINK
创建dblink:
1
2
3
4
5
6
7
8
9
10
11
|
create
database
link [
name
]
connect
to
[username] IDENTIFIED
BY
[
password
]
using
'(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = [ip])(PORT = [port]))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xxx)
)
)'
;
|
例如:
1
|
create
public
database
link dblink_name
connect
to
SYSTEM using
'192.168.1.73:1521/oracle'
;
删除dblink:
|