【oracle】用户与安全管理

版权声明:原创手打 转载请注明来源 https://blog.csdn.net/qq_42774325/article/details/81913112
  1. 查询当前数据库系统中的用户信息:用户名、默认表空间、临时表空间、用户创建时间、用户状态
    select username,default_tablespace,temporary_tablespace,created,account_status from dba_users;
     
     
  2. 创建一个用户:u1 密码为:oracle,不指定默认表空间与临时表空间,在创建的时候讲用户锁住
    create user u1 identified by oracle account lock;
     
     
  3. 查询刚才创建的用户的信息:用户名、默认表空间、临时表空间、用户创建时间、用户状态
    select username,default_tablespace,temporary_tablespace,created,account_status from dba_users where username=’U1’;
     
     
  4. 查询当前数据库中有哪些系统权限
    select * from dba_sys_privs;
     
     
  5. 查询当前数据库有哪些角色
    select * from dba_roles;
     
     
  6. 查询刚刚穿件的用户是否有权限角色
    select * from dba_sys_privs where grantee=’U1’;
    结果为没有
     
     
  7. 创建一个表空间:tbs2,大小为50M,数据文件的位置与现有表空间位置一样
    select * from v$tablespace;
    查询现有的表空间
     
    select name from v$datafile;
    查询现有表空间的路径
     
    create tablespace tbs2 datafile
    ‘/u02/app/oracle/oradata/orcl/tbs201.dbf’ size 50M;
     
  8. 修改刚刚创建好的用户的默认表空间为tbs2,临时表空间为temp
    alter user u1 default default tablespace tbs2;
     
    alter user u1 temporary tablespace temp;
     
     
  9. 给用户授予可以创建回话的权限
    grant create session to u1;
     
     
  10. 修改刚刚创建用户的状态,将其解锁,并使用用户连接
    alter user u1 account unlock;
     
     
     
  11. 创建一个角色名为:role1密码为oracle
    create role role1 identified by oracle;

 

12、把系统预定义的两个角色connect,resource授给刚刚穿件的角色role1
grant connect,resource to role1;
 
 

13、把刚创建的角色role1授予给用户u1,并查询用户u1现在有哪些权限
grant role1 to u1;
 
select granted_role from dba_role_privs where grantee=’U1’;
 
select granted_role from dba_role_privs where grantee=’ROLE1’;
 
select * from dba_sys_privs where grantee in (‘CONECT’,’RESOURCE’);
 
 

14、讲用户HR下的表employees,departments的查询权限授予给用户u1
conn hr/hr
grant select on departments to u1;
 
grant select on employees to u1;
 
 

15、新创建一个用户u2,密码为oracle,默认表空间为tbs2.临时表空间为temp
create user u2 identified by oracle default tablespace tbs2 temporary tablespace temp;
 

16、从用户u1回收create table权限,并重新授予create table权限,并加选项:with admin option
grant create table to u1;
 
revoke create table from u1;
 
grant create table to u1 with admin option;
 
 

17、连接到u2,创建一张测试表test1(id number(3),name varchar2(100))

conn u1

grant create table to u2;

create table test1(id number(3),name varchar2(100));

 
 

18、用SYS用户将用户U1的create table 的权限回收,在连接到用户U2验证是否还可以创建表
conn / as sysdba
revoke create table u1;
 
conn u2
create table test2(id number(3));
结果为在u1被权限回收以后u2还可以创建表

猜你喜欢

转载自blog.csdn.net/qq_42774325/article/details/81913112