创建一个只有select 权限的用户
2010-01-28 19:46
429 查看
添加用户NewA对用户OldB只有select 的权限步骤:
1. 新建用户
SQL> create user newA identified by"admin";
用户已创建。
SQL> grant connect,resource to newA;
授权成功。
SQL>
2.用OldB(如:scott)进行连接,用拼字符串的方式来将scott用户的select权限赋予新用户newA,并执行拼成的select串。
SQL> conn scott/admin;
已连接。
SQL> Select 'grant select onscott.'||table_name||' to newA;' from user_tables;
'GRANTSELECTONSCOTT.'||TABLE_NAME||'TONEWA;'
-------------------------------------------------------------
grant select on scott.DEPT to newA;
grant select on scott.EMP to newA;
grant select on scott.BONUS to newA;
grant select on scott.SALGRADE to newA;
SQL> grant select on scott.DEPT to newA;
授权成功。
SQL> grant select on scott.EMP to newA;
授权成功。
SQL> grant select on scott.BONUS tonewA;
授权成功。
SQL> grant select on scott.SALGRADE tonewA;
授权成功。
SQL>
或者通过命令:
SQL>grant select any table to newuser;
3. 创建同义词:拼创建同名词串,要赋予新用户create synonym的权限。
SQL> conn / as sysdba
已连接。
SQL> grant create synonym to newA;
授权成功。
SQL>
SQL> conn scott/admin;
已连接。
SQL> select 'create synonym '||table_name ||' for scott.'|| table_name ||';' fr
om user_tables;
'CREATESYNONYM'||TABLE_NAME||'FORSCOTT.'||TABLE_NAME||';'
---------------------------------------------------------------------------
create synonym DEPT for scott.DEPT;
create synonym EMP for scott.EMP;
create synonym BONUS for scott.BONUS;
create synonym SALGRADE for scott.SALGRADE;
4. 用新用户连接,执行上面创建的同名词串,然后就可以查询scott用户的所有表了,这样就跟查询自己的表一样。在实际工作中。给与其他用户对自己表的查询权限是很有用的。
SQL> conn newa/admin;
已连接。
SQL> create synonym DEPT for scott.DEPT;
同义词已创建。
SQL> create synonym EMP for scott.EMP;
同义词已创建。
SQL> create synonym BONUS forscott.BONUS;
同义词已创建。
SQL> create synonym SALGRADE forscott.SALGRADE;
同义词已创建。
SQL>
SQL> conn newa/admin;
已连接。
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> drop dept;
drop dept
*
第 1 行出现错误:
ORA-00950: 无效DROP 选项
操作结束,现在新用户newA已经对scott用户的所有表都具有了查询的权限。
-------------------------------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
Weibo: http://weibo.com/tianlesoftware
Email: dvd.dba@gmail.com
DBA1 群:62697716(满); DBA2 群:62697977(满) DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群: 83829929(满) DBA5群: 142216823(满)
DBA6 群:158654907(满) 聊天 群:40132017(满) 聊天2群:69087192(满)
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请
1. 新建用户
SQL> create user newA identified by"admin";
用户已创建。
SQL> grant connect,resource to newA;
授权成功。
SQL>
2.用OldB(如:scott)进行连接,用拼字符串的方式来将scott用户的select权限赋予新用户newA,并执行拼成的select串。
SQL> conn scott/admin;
已连接。
SQL> Select 'grant select onscott.'||table_name||' to newA;' from user_tables;
'GRANTSELECTONSCOTT.'||TABLE_NAME||'TONEWA;'
-------------------------------------------------------------
grant select on scott.DEPT to newA;
grant select on scott.EMP to newA;
grant select on scott.BONUS to newA;
grant select on scott.SALGRADE to newA;
SQL> grant select on scott.DEPT to newA;
授权成功。
SQL> grant select on scott.EMP to newA;
授权成功。
SQL> grant select on scott.BONUS tonewA;
授权成功。
SQL> grant select on scott.SALGRADE tonewA;
授权成功。
SQL>
或者通过命令:
SQL>grant select any table to newuser;
3. 创建同义词:拼创建同名词串,要赋予新用户create synonym的权限。
SQL> conn / as sysdba
已连接。
SQL> grant create synonym to newA;
授权成功。
SQL>
SQL> conn scott/admin;
已连接。
SQL> select 'create synonym '||table_name ||' for scott.'|| table_name ||';' fr
om user_tables;
'CREATESYNONYM'||TABLE_NAME||'FORSCOTT.'||TABLE_NAME||';'
---------------------------------------------------------------------------
create synonym DEPT for scott.DEPT;
create synonym EMP for scott.EMP;
create synonym BONUS for scott.BONUS;
create synonym SALGRADE for scott.SALGRADE;
4. 用新用户连接,执行上面创建的同名词串,然后就可以查询scott用户的所有表了,这样就跟查询自己的表一样。在实际工作中。给与其他用户对自己表的查询权限是很有用的。
SQL> conn newa/admin;
已连接。
SQL> create synonym DEPT for scott.DEPT;
同义词已创建。
SQL> create synonym EMP for scott.EMP;
同义词已创建。
SQL> create synonym BONUS forscott.BONUS;
同义词已创建。
SQL> create synonym SALGRADE forscott.SALGRADE;
同义词已创建。
SQL>
SQL> conn newa/admin;
已连接。
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> drop dept;
drop dept
*
第 1 行出现错误:
ORA-00950: 无效DROP 选项
操作结束,现在新用户newA已经对scott用户的所有表都具有了查询的权限。
-------------------------------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
Weibo: http://weibo.com/tianlesoftware
Email: dvd.dba@gmail.com
DBA1 群:62697716(满); DBA2 群:62697977(满) DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群: 83829929(满) DBA5群: 142216823(满)
DBA6 群:158654907(满) 聊天 群:40132017(满) 聊天2群:69087192(满)
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请
相关文章推荐
- 创建一个只有select 权限的用户
- 创建一个对另外一个用户表只有select权限的用户-实用
- 创建一个只有select 权限的用户
- 创建一个只有select 权限的用户
- 创建一个只有select 权限的用户
- 创建一个只有select 权限的用户
- 创建一个只有select 权限的用户
- 创建只有SELECT权限的用户
- 在sql server上创建一个只有单一访问权限的用户
- HTML基础 form-select创建只有一级的下拉列表,不选的时候只显示一个
- Oracle下批量将一个用户的所有表的select权限赋值给另外一个用户
- 给mysql添加一个只有某个数据库查询权限的用户
- exchange 管理员只有创建新用户无删除的权限设定方法
- ubuntu创建一个用户,且具备sudo权限
- 第一安装oracle数据库后,需要创建一个用户,给用户解锁并赋予权限
- zk Acl权限:只有一个账号有crdwa权限,匿名用户只有r权限
- oracle创建新用户只有mes账户下四张表的查询权限
- MySQL, 创建一个只读用户和一个所有权限用户
- mysql 禁止root用户远程登录,创建一个只读权限用户进行远程登录
- 给一个普通用户有在他的目录下有创建文件的权限