查看登陆的用户:以下都可以: show user; select sys_context(
查看登陆的用户:
以下都可以:
show user;
select sys_context(‘userenv’,’session_user’) from dual;
select user from dual;
查看所有登录的用户必须为dba 用户:
select username from v$session;
sys、system等dba 用户查看 其他用户(test)中的对象(表):
sql> select * from test.student;
创建一个普通用户都把该用户用起来的流程:
1、创建用户
sql>create user test indentified by test;
这样就创建了一个用户名密码都为test的用户
但这个时候test还是不能登陆成功的,我们需要赋予相应的权限
2、赋予create session的权限
sql>grant create session to test;
这样test用户就能成功登陆进去
但是此时用户还是不能创建表 我们需要赋予用户创建表的权限:
sql>grant create table to test;
但是用户此时还不能创建表 因为需要有使用表空间的权限(相当于 用户有了进房间的钥匙 但是没有进大门的钥匙。。。)
所以也应该赋予相应的权限
sql>grant unlimited tablespace to test;
这个时候用户就拥有了创建表的权限 由于表是用户test的 相应的他就拥有了对创建的表的增删查改的权限了
3、查看用户拥有什么权限可以通过查询一个系统的视图(数字字典)
sql>select * from user_sys_privs;
这样就可以知道当前用户的权限
4、撤销权限
sql> revoke create table from test;
—————————–
一些常用视图的区分
dba_tables dba_all_tables user_tables user_all_tables all_tables all_all_tables
当前用户所属的所有表(注意大写)
sql> select tablespace_name,table_name from user_all_tables where table_name=’student’;
sql> select table_name,tablespace_name from user_tables where table_name=’student’;
table_name tablespace_name
—————————— ——————————
student users
sys 要查看dba_all_tables,all_all_tables才能查看到 test 用户的表。
sql> select owner,table_name,tablespace_name from dba_all_tables where owner=’test’;
sql> select owner,table_name,tablespace_name from all_all_tables where owner=’test’;
sql> select owner,table_name,tablespace_name from dba_tables where owner=’test’;
sql> select owner,table_name,tablespace_name from all_tables where owner=’test’;
owner table_name tablespace_name
—————————— —————————— ——————————
test student users
1.dba_all_tables describes all object tables and relational tables in the database. its columns are the same as those in all_all_tables.
2.all_all_tables describes the object tables and relational tables accessible to the current user.
3.user_all_tables describes the object tables and relational tables owned by the current user. its columns (except for owner) are the same as those in
all_all_tables.
———————————————————————-
情景一:
用户test 用户test1
test1的用户创建了个表mytab 并且插入了一些数据
那么 test用户是否可以访问到test1的mytab怎么访问?
答:不可以,必须先授权
test1必须授权给test :grant select on mytab to test;
那么这个时候test可以通过 select * from test1.mytab;来访问mytab中的数据
如果想把某个表(对象)的所有权限都赋予给test那么可以:
grant all on mytab to test;
撤销所有权限
revoke all on mytab to test;
总结
对于系统权限由sys来做
对于对象权限由 谁拥有谁授权
系统权限
grant create session to test;
grant create table to test;
grant unlimited tablespace to test;
revoke create session from test;
revoke create table from test;
revoke unlimited tablespase from test;
grant create session to public; //表示把创建表的权限赋予所有人
select * from user_sys_privs; //返回当前用户的所有系统权限
对象权限
grant select on mytab to test;
grant all on mytab to test;
revoke select on mytab from test;
revoke all on mytab from test;
select * from user_tab_privs; //返回当前用户所有的对象权限
对象权限可以控制到列
grant update(name) on mytab to test;
grant insert(id) on mytab to test;
select * from user_col_privs;
注意、:查询和删除不能控制到列
需要有commit的 insert update insert
权限的传递
系统权限的传递:
grant alter table to a with admin option;
那么a可以通过把该权限传递给b,,如果想b也可以传递下去那么可以也带上with admin option
grant alter table to b;
对象权限的传递:
grant select on mytab to a with grant option;
那么a可以把在表mytab的select权限赋予给b,如果b想也能传递该select权限也可以带上with grant option
grant select on mytab to b;
登陆em 的用户必须有一下权限
创建了一个用户testem,并有如下授权
create user testem identified by testem;
grant create session,select any dictionary to testem; // testem可以登陆em,但是还不是em的管理员。
grant mgmt_user to testem;
非em管理员:(在“管理”下面没有下图选项)
通过em 登陆来增加 em管理员:
名称:testem
电子邮件地址没有为此管理员定义电子邮件地址。
有权访问所有目标的超级管理员权限。
数据库系统权限: select any dictionary
数据库角色: mgmt_user
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/1932878.html