如果想让某个用户查看视图又不想让他看到其它内容,那么可以使用下面方法进行授权。
主帐户下执行
grant select on view_name to new_user;
new_user下执行
create or replace synonym view_name
for GISAP.view_name;
示例:
--用sys用户登录,建立对外开放的用户
CREATE USER NBXZ IDENTIFIED BY GPS2011
DEFAULT TABLESPACE GISAP
TEMPORARY TABLESPACE TEMP
QUOTA UNLIMITED ON GISAP;
--用gisap用户登录,建立对外开放的视图
CREATE OR REPLACE VIEW V_Vehicle_History AS
select c.corpname, v.number_plate, u.call_letter, v.vehiclecolor,
h.gpstime, h.lon, h.lat, h.course, h.speed, h.LOC_STATE
from t_history h, t_unit u, t_vehicle v, xz_sp_corp_unit scu, xz_corp c
where h.call_letter = u.call_letter
and u.unitid = v.unitid
and u.unitid = scu.unitid
and scu.corpid = c.id
--授对外访问
grant select on V_Vehicle_History to NBXZ;
create or replace synonym V_Vehicle_History for GISAP.V_Vehicle_History;
--外部单位使用NBXZ用户登录(密码是:GPS2011),后访问以下视图
select * from v_vehicle_history