给的建议是修改sys,system默认账户名称,避免使用常见用户名称;
以下记录了两种方法来实现上面的要求:Oracle重命名sys操作记录
方法一:通过用户的信息是存储在user$实体表中的id来修改
1.1、首先获取用户的id
select username,user_id from dba_users where username=‘SYS‘;
USERNAME USER_ID
------------------------------ ----------
SYS 0
或者:
select user#,name from user$ where name=‘SYS‘;
USER# NAME
---------- ------------------------------
0 SYS
1.2、更新user$表中的记录(注意:在更新的时候,新的名字SYSA必须为大写)
SQL> update user$ set name=‘SYSA‘ where user#=0;
1 row updated.
SQL> commit;
Commit complete.
SQL> alter system checkpoint;
System altered.
SQL> alter system flush shared_pool;
System altered.
SQL> conn sysa/sys as sysdba
Connected.
方法二:通过修改Oracle的隐含参数,_enable_rename_user来开启Oracle的rename功能
2.1、查看_enable_rename_user
SQL> select t1.ksppinm,t2.ksppstvl,t1.ksppdesc from x$ksppi t1,x$ksppcv t2 where t1.indx=t2.indx and t1.ksppinm like ‘_enable_rename_use
r‘;
KSPPINM
--------------------------------------------------------------------------------
KSPPSTVL
--------------------------------------------------------------------------------
KSPPDESC
--------------------------------------------------------------------------------
_enable_rename_user
FALSE
enable RENAME-clause using ALTER USER statement
2.2、修改_enable_rename_user(注意:在修改隐含参数时,参数必须用双引号引起来)
SQL> alter system set "_enable_rename_user"=true scope=spfile;
System altered.
2.3、将数据启动到restrict模式下:
SQL> startup restrict force
ORACLE instance started.
Total System Global Area 3290345472 bytes
Fixed Size 2232840 bytes
Variable Size 1795165688 bytes
Database Buffers 1476395008 bytes
Redo Buffers 16551936 bytes
Database mounted.
Database opened.
2.4、操作修改rename user
SQL> alter user sysa rename to sys identified by syspwd;
User altered.
第二种方法需要重启数据库,没有方法一快捷
Oracle重命名sys或system操作记录
原文:https://blog.51cto.com/8355320/2529771