Oracle 给用户授权访问视图
Oracle 给用户授权访问视图
create user c##hrp identified by 123456;
grant resource,connect to c##hrp;
grant connect to c##hrp;
grant select on C##BSKJ.sch_sc_schedulinfo to c##hrp;
grant select on C##BSKJ.sch_sc_classes to c##hrp;
grant select on C##BSKJ.sys_user to c##hrp;
SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE='VIEW' and OBJECT_NAME='XISOFT_HLPBSJ'
SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE='VIEW' and OBJECT_NAME='XISOFT_HLDYRYSJ'
SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE='VIEW' and OBJECT_NAME='XISOFT_HLBCSJ'
GRANT SELECT ON C##BSKJ.XISOFT_HLPBSJ to c##hrp;
grant select on C##BSKJ.XISOFT_HLPBSJ to c##hrp;
grant select on C##BSKJ.XISOFT_HLDYRYSJ to c##hrp;
grant select on C##BSKJ.XISOFT_HLBCSJ to c##hrp;
--需要用新建的用户查询
select * from c##bskj.XISOFT_HLPBSJ
select * from c##bskj.sys_user
创建用户
create user 创建的用户名 identified by 创建的用户名的密码
赋予用户视图权限
grant create view to 创建的用户名;
赋予用户视图权限
grant select on 所属账户.视图名 to 创建的用户名;
连接数据库权限
grant connect to 创建的用户名
后面直接登录账户链接测试
select * from 所属账户.视图名
视图
-- XIsoft_hldyrysj
CREATE OR REPLACE VIEW XIsoft_hldyrysj
as
select su.office_id as atdeptcode,
so.name as atdeptname,
'' as person_leaderid_number,
su.id as person_id_number,
su.name as persion_name,
'' as isscheduing,
'' as startdate,
'' as enddate,
'' as reason
from sys_user su, sys_office so
where su.office_id = so.id
order by so.name, su.name;
-- XIsoft_hlbcsj
CREATE OR REPLACE VIEW XIsoft_hlbcsj
as
select ssc.dept_id as atdeptcode,
ssc.classes_id as classcode,
ssc.classes_name as classname,
ssc.alias as abbreviation,
ssc.classes_type as type_name,
(case
when ssc.classes_begintime1 is not null then
ssc.classes_begintime1 || '-' || ssc.classes_endtime1
else
''
end) || (case
when ssc.classes_begintime2 is not null then
',' || ssc.classes_begintime2 || '-' || ssc.classes_endtime2
else
''
end) as worktime,
(case
when ssc.classes_begintime1 is not null then
ssc.classes_begintime1
else
''
end) as starttime,
(case
when ssc.classes_endtime2 is not null then
ssc.classes_endtime2
when ssc.classes_endtime1 is not null then
ssc.classes_endtime1
else
''
end) as endtime,
(case
when ssc.classes_begintime2 is not null then
ssc.classes_endtime1
else
''
end) as Reststrattime,
(case
when ssc.classes_begintime2 is not null then
ssc.classes_begintime2
else
''
end) as Restendtime,
'' as workinghours,
ssc.classes_fcolor as color,
ssc.is_enabled as isschedule
from sch_sc_classes ssc;
-- XIsoft_hlpbsj
CREATE OR REPLACE VIEW XIsoft_hlpbsj
as
select ssc.dept_id as atdeptcode,
to_char(sss.scheduling_date, 'yyyy-mm-dd') as DAY,
sss.person_id as person_id_number,
su.name as persion_name,
ssc.classes_id as classcode,
ssc.classes_name as classname,
'' as STATUS,
sss.scheduling_remark as remark
from sch_sc_schedulinfo sss, sch_sc_classes ssc, sys_user su
where sss.class_id = ssc.classes_id
and sss.person_id = su.id
order by atdeptcode, DAY, person_id_number;