Oracle为用户设置读权限

Oracle 数据库中创建表只读用户,并为其设置密码永不过期、同义词。

1.创建用户
create user test
  identified by "123456"
  default tablespace db
  temporary tablespace dbTEMP;
2.资源授权
grant connect,resource to test;

3.表授读权限
select 'grant select on '|| table_name|| ' to test;' from user_tables order by table_name

4.密码永不过期
单独创建一个profile文件,为某用户使用。
创建名为passwd_unlimit的profile文件,设置其profile下密码限定为永不过期。
create profile  passwd_unlimit limit PASSWORD_LIFE_TIME unlimited;

把passwd_unlimit的初始化参数设置到test用户下。如下:
alter user test profile passwd_unlimit;

设置完成后,通过dba_users查看一下test用户的profile文件是否设置成功,如下:
select username,user_id,account_status,expiry_date, profile from dba_users  where username ='test';

可以看到test用户的profile文件设置为了passwd_unlimit,而passwd_unlimit的profile文件设定为密码永不过期了。
最后,命名为PASSWD_UNLIMIT的profile文件下所附属的资源设置都有哪些,如下:
SELECT * FROM dba_profiles WHERE profile = 'PASSWD_UNLIMIT';

5.同义词
select 'create synonym test.'|| table_name|| ' for db.'||table_name||';' from user_tables
order by table_name 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章