用户权限管理

select * from dba_sys_privs where GRANTEE like '%STJT%';
select * from dba_role_privs where GRANTEE like '%STJT%';
select * from dba_tab_privs where GRANTEE like '%STJT%';

修改用户的默认表空间:
alter uesr EAPCX2 default tablespace APC_DATA2;
select * from dba_sys_privs where GRANTEE like '%SIMAXX%';
grant connect,resource,dba to username;

修改用户密码:
alter user username identfied by 111111;
创建用户:create user username identfied by 111111 default tablespace APC_DATA2 temporary tablespace temp;
用户授权:grant connect,resource,dba to username;
commit;
查看数据库用户信息:select * from dba_users;
查看用户状态:select usrname,account_status from dba_users;
查看用户默认使用的表空间:
select username,default_tablespace,temporary_tablespace,con_id from dba_users where username='IF_MATS';
select username,default_tablespace,temporary_tablespace from dba_users where username='IF_MATS';

dba_objects可以查表的最后修改日期

grant unlimited tablespace to IF_MATS;
grant create any synonym to IF_IWP;
grant ALTER ANY PROCEDURE,ALTER ANY TRIGGER,CREATE ANY INDEX,CREATE ANY PROCEDURE,CREATE ANY VIEW,RESOURCE,CREATE TRIGGER,DROP ANY TRIGGER,EXECUTE ANY PROCEDURE,SELECT ANY DICTIONARY,UNLIMITED TABLESPACE,CONNECT,CREATE JOB,CREATE VIEW,SELECT ANY TABLE to FMCSTOT;

ora-28003
ora-20000
set line 200 pagesize 2000
col profile for a20
col LIMIT for a30
select * from dba_profiles order by profile;
create user FMCSTOT identified by "ORAX2" default tablespace TS_MASTR_D profile SHORT_PW_PROFILE;
alter user FMCSTOT profile default;

RESOURCE_NAME:
PASSWORD_VERIFY_FUNCTION
(LIMIT IS NULL),这个就是密码的强度,显示null就是对密码强度不限制
alter user FMCSTOT profile ;
TEMPPROFILE:先改为这个,不限制密码强度
alter user FMCSTOT profile default; 再改回来

ORA-28007:the password cannot be reused错误
原因:被profile设置了
1.用下面语句查询glbquery用户使用的profile的名字
select profile from dba_users where username=upper'(glbquery');
output:PUB_USERNLSLIMIT_PROF
2.用下面语句查询profile的值
select profile,resource_name,limit from dba_profiles where profile='PUB_USERNLSLIMIT_PROF';
3.用下面语句改值为unlimited
alter profile PUB_USERNLSLIMIT_PROF limit PASSWORD_REUSE_MAX unlimited;
alter profile PUB_USERNLSLIMIT_PROF limit PASSWORD_REUSE_TIME unlimited;
4.改glbquery的密码
alter user glbquery identified by huawei123;
5.用以下命令修改profile的值
alter profile PUB_USERNLSLIMIT_PROF limit PASSWORD_REUSE_MAX default;
alter profile PUB_USERNLSLIMIT_PROF limit PASSWORD_REUSE_TIME=5;

dba_sys_privs
dba_role_privs
dba_tab_privs

create any synonym 和create synonym 区别
Oracle系统提供三种权限:object对象级,system系统级,role角色级
权限授予可以给用户和角色,角色是权限的集合

系统权限管理
系统权限分类:
DBA:拥有全部特权,是系统最高权限,只有DBA才可以创建数据库结构。
RESOURCE:拥有resource权限的用户只可以创建实体,不可以创建数据库结构。
CONNECT:拥有connect权限的用户只可以登录oracle,不可以创建实体,不可以创建数据库结构。
对于普通用户:授予connect,resource权限。
对于DBA管理用户,授予connect,resource,dba权限
系统权限授权命令:系统权限只能由dba用户授予:sys,system(最开始只能是这两个用户)
授权命令:grant connect,resource,dba to 用户名1 [用户名2]...;

实体权限管理
实体权限分类
select,update,insert,alter,index,delete,all //all包括所有权限
execute //执行存储过程权限
user01:
grant select ,update,insert on product to user02;
grant all on product to user02;
user02:
select * from user01.product; //此时user02查user_tables,不包括user.product这个表,但如果查all_tables则可以查到,因为它可以访问。将表的操作授予全体用户;
grant all product to public; //public表示所有的用户,这里的all权限不包括drop。

管理角色
建一个角色
create role role1;
授予给角色
grant create any table,create procedure to role1;
授予角色给用户
grant role1 to user1;
查看角色所包含的权限
select * from role_sys_privs;
创建带有口令以角色(在生效带有口令的角色时必须提供口令)
create role role1 identified by password1;
修改角色:是否需要口令
alter role role1 not identified;
alter role role1 identified by password1;
删除角色
drop role role1;
角色删除后,原来用该角色的用户就不再拥有该角色了,相应的权限也就没有了;

with admin option:针对用户授予系统权限,可以让被授予用户继续授予其他用户权限,但是回收时不会级联回收
with grant option:针对用户授予对象权限,可以让被授予用户继续授予,但是回收时会产生联级效应

posted @ 2025-03-05 08:31  ocmji  阅读(46)  评论(0)    收藏  举报