SQL> select *
2 from session_privs
3 where privilege like 'ALTER ANY%';
PRIVILEGE
----------------------------------------
ALTER ANY TABLE
ALTER ANY CLUSTER
ALTER ANY INDEX
ALTER ANY SEQUENCE
ALTER ANY ROLE
ALTER ANY PROCEDURE
ALTER ANY TRIGGER
ALTER ANY MATERIALIZED VIEW
ALTER ANY TYPE
ALTER ANY LIBRARY
ALTER ANY OPERATOR
ALTER ANY INDEXTYPE
ALTER ANY DIMENSION
ALTER ANY OUTLINE
ALTER ANY EVALUATION CONTEXT
ALTER ANY RULE SET
ALTER ANY RULE
ALTER ANY SQL PROFILE
ALTER ANY EDITION
ALTER ANY ASSEMBLY
ALTER ANY MINING MODEL
ALTER ANY CUBE DIMENSION
ALTER ANY CUBE
ALTER ANY SQL TRANSLATION PROFILE
ALTER ANY MEASURE FOLDER
ALTER ANY CUBE BUILD PROCESS
ALTER ANY ATTRIBUTE DIMENSION
ALTER ANY HIERARCHY
ALTER ANY ANALYTIC VIEW
29 rows selected.
SQL> alter user sys identified by newpass;
alter user sys identified by newpass
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL>select banner
2 from v$version
3 /
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Solaris: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
要修改用户的密码,需要“ALTER USER”权限。
SQL>connect / as sysdba
Connected.
SQL>create user myuser identified by myuser;
User created.
SQL>grant create session to myuser;
Grant succeeded.
SQL>grant alter user to myuser;
Grant succeeded.
SQL>connect myuser/myuser
Connected.
SQL>alter user sys identified by HalloWorld;
User altered.
SQL>
所以 ALTER USER 是一个非常危险的特权。用户可以更改 SYS 密码,以 SYS 身份登录,并可以修改/读取/删除数据库。因此,您应该执行以下操作
SQL>connect / as sysdba
Connected.
SQL>create user secure identified by secure;
User created.
SQL>grant create procedure to secure;
Grant succeeded.
SQL>grant alter user to secure;
Grant succeeded.
SQL>create or replace procedure secure.change_syspw(new_syspw varchar2)
2 as
3 begin
4 EXECUTE IMMEDIATE 'alter user sys identified by "'||new_syspw||'"';
5 end;
6 /
Procedure created.
SQL>create user myuser identified by myuser;
User created.
SQL>grant create session to myuser;
Grant succeeded.
SQL>grant execute on secure.change_syspw to myuser;
Grant succeeded.
SQL>connect myuser/myuser
Connected.
SQL>exec secure.change_syspw('HalloWorld')
PL/SQL procedure successfully completed.
SQL>
您需要以具有 SYSDBA 权限的用户身份进行连接。即使“更改任何用户”也不够。
我认为这是不明智的。
SYS 密码不仅可以供Oracle 数据库使用。
DataGuard Broker 和 Enterprise Manager 是我想到的两个。后者将在某个时候将 SYS 密码存储在其中(鉴于 OEM 倾向于为您“记住”事情,这几乎是不可避免的)因此定期更改 SYS 密码可能会给您带来问题。
我似乎还记得 OEM代理也可以使用它(用于自动故障转移?)所以定期从您下面更改此密码比您想象的要危险得多。
我在这里假设您的意思是 SYS 密码,复数,因为当然,每个Oracle 安装都必须有自己的凭据,与其他所有安装分开,并且您必须至少有两个安装(测试和实时)!
我正在使用 Oracle 11.2:
要修改用户的密码,需要“ALTER USER”权限。
所以 ALTER USER 是一个非常危险的特权。用户可以更改 SYS 密码,以 SYS 身份登录,并可以修改/读取/删除数据库。因此,您应该执行以下操作
这是一个例子
这是 12.2 中记录的行为更改:
RDBMS 12.2 - 被授予 ALTER USER 系统权限的用户无法更改 SYS 密码(文档 ID 2263715.1)