您的位置:首页 > 数据库 > Oracle

oracle学习记录之授权(1)

2013-01-03 14:12 375 查看
oracle学习记录,表上查询、执行存储过程的授权,grant语句的使用,供参考。

--以sys用户连接数据库,密码oracle
connect sys/oracle as sysdba;
--创建test1用户,密码123
create user test1 identified by 123;
--建立测试表a
create table a(a number(10), b varchar2(20));
--把查询a表的权限授給test1
grant select on a to test1;
--建立测试存储过程spAdd
create procedure spAdd (aa in number, bb in varchar2)
as
begin
insert into a values(aa, bb);
commit;
end;
/
--sys执行存储过程
execute spAdd(123, 'aaa');
--把执行存储过程的权限授給test1
grant execute on spAdd to test1;
--把create session权限授给test1
grant create session to test1;
--以test1用户连接数据库
connect test1/123;
--以test1用户执行sys的spAdd存储过程
execute sys.spAdd(124, 'bbb');
--以test1用户查询sys的a表
select * from sys.a;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: