一般修改用户名大多使用导出用户a再导入用户b来实现用户名的换名。假如在测试库上你可以用下面的方法来简单实现,这样就不用导出了。注释:重要的生产库不建议这样做,可能会引发其它的问题UPDATE USER$ SET NAME='A2B' WHERE NAME='HH';
--注意:要改成的用户名必需为大写,因为系统表里用户名都是大写的,否则下面的alter user a2b identified by a;操作会报错,说找不到用户。
ALTER SYSTEM CHECKPOINT;--强制写入数据文件
ALTER SYSTEM FLUSH SHARED_POOL;--清除缓存数据字典信息
alter user a2b identified by a;
SQL> conn hh/a
Connected.
SQL> SELECT COUNT(*) FROM USER_OBJECTS;
COUNT(*)
----------
952
SQL> conn / as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> UPDATE USER$ SET NAME='A2B' WHERE NAME='HH';
1 row updated.
SQL> commit;
Commit complete.
SQL> ALTER SYSTEM CHECKPOINT;
System altered.
SQL> ALTER SYSTEM FLUSH SHARED_POOL;
System altered.
SQL> alter user a2b identified by a;
User altered.
SQL> conn a2b/a
Connected.
SQL> SELECT COUNT(*) FROM USER_OBJECTS;
COUNT(*)
----------
952