1.以sys登录到数据库,建立以下数据库用户并授权。
(1)用户名:abc,口令:oracle
create user abc identified by oracle;
(2)用户名:xyz,口令:oracle
create user xyz identified by oracle;
(3)为abc用户授予系统权限create session、create table,并带有with admin option选项。
grant create session,create table to abc with admin option;
2.以abc用户登录,执行下列操作
(1)将abc用户的口令改为abc。
alter user abc identified by abc;
(2)查询abc用户有哪些系统权限。
connect abc/abc
select * from user_sys_privs;
(3)创建表t1,语句为create table t1(cola int),并检查能否执行成功。
create table t1(cola int);
(4)在abc用户下,为xyz用户授予权限create session、create table,然后以xyz用户登录,创建表t1。
grant create session,create table to xyz;
connect xyz/oracle
create table t1(cola int);
3.以sys登录,收回abc用户的create table权限,然后分别以abc和xyz登录创建表t2,检查能否执行成功。
connect sys/Oracle11 as sysdba
revoke create table from abc;
connect abc/abc
create table t2(cola int);
connect xyz/oracle
create table t2(cola int);
4.以Scott登录,将查询dept表的对象权限授予用户abc(带有with grant option),将更新dept表loc列的权限授予用户abc。以abc登录,查询Scott.dept的数据,更新部门10的部门位置和部门名,接着查询SCOTT.DEPT表的权限,并将更新dept表loc列的权限转授给xyz,检查是否成功。
connect sys/Oracle11 as sysdba
alter user scott identified by tiger account unlock;
connect scott/tiger
grant select on dept to abc with grant option;
grant update(loc) on dept to abc;
connect abc/abc
select * from scott.dept;
update scott.dept set dname=666 where deptno=10;/*更新部门10的部门部门名*/
update scott.dept set loc=666 where deptno=10;/*更新部门10的部门部门名*/
select * from user_tables;/*查询SCOTT.DEPT表的权限*/
grant update(loc) on dept to xyz;/*更新dept表loc列的权限转授给xyz*/
5.以scott登录,回收abc用户查询dept的权限,然后分别以abc、xyz用户登录,查询Scott的dept表的数据,检查能否成功。
connect scott/tiger
revoke select on dept from abc;
connect abc/abc
select * from scott.dept; //不成功
connect xyz/oracle
select * from scott.dept;