ایجاد دسترسی View به User در اوراکل
ابتدا در اوراکل با یوزر sys – connect شوید. سپس سه تا یوزر ایجاد کنید.
create user test10 identified by test10;
/
grant connect,resource to test10;
/
create user test20 identified by test20
/
grant connect,resource to test20;
/
create user test30 identified by test30
/
/
grant connect,resource to test10;
/
create user test20 identified by test20
/
grant connect,resource to test20;
/
create user test30 identified by test30
/
جدولی به نام t1 را در اسکیمای test30 در اوراکل ایجاد کنید و دسترسی select را به اسکیمای test20 دهید.
create table test30.t1(f1 number);
/
grant select on test30.t1 to test10;
/
/
grant select on test30.t1 to test10;
/
در این مرحله یک view به نام t1_view رابرروی جدول test30.t1 در اوراکل ایجاد کنید.
create view test10.t1_view as
Select * from test30.t1
/
Select * from test30.t1
/
تا به اینجا همه چیز بصورت نرمال عمل می کند. حال می خواهیم دسترسی select بر روی view را به یوزر test20 دهیم.
Grant select on test10.t1_view to test20
/
/
با یوزر test20 وصل شوید و دستور زیر را اجرا کنید. خطای زیر در اوراکل ظاهر می شود:
ORA-01031: insufficient privileges
کاملا صحیح می باشد. زیرا دسترسی test30.t1 به اسکیمای test فقط بعنوان یک استفاده کننده داده شده است نه اینکه بخواهد خودش را بعنوان owner جدول جا بزند و دسترسی دهد. برای این منظور باید بصورت زیر عمل کنید.
grant select on test30.t1 to test10 with grant option
/
grant select on test30.t1 to test10 with grant option
/