博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[20170628]11g修改用户名.txt
阅读量:6072 次
发布时间:2019-06-20

本文共 3152 字,大约阅读时间需要 10 分钟。

[20170628]11g修改用户名.txt

--//昨天看了链接,提到修改用户名:
http://www.oratea.com/2017/06/26/oracle-11g%e4%bf%ae%e6%94%b9%e7%94%a8%e6%88%b7%e5%90%8d/
--//自己也测试看看.
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING         VERSION    BANNER
------------------- ---------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SYS@book> grant dba to sss IDENTIFIED BY sss;
Grant succeeded.
SYS@book> @ &r/hide _enable_rename_user
NAME                DESCRIPTION                                     DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
------------------- ----------------------------------------------- ------------- ------------- ------------
_enable_rename_user enable RENAME-clause using ALTER USER statement TRUE          FALSE         FALSE
--//缺省值是false.
--//从Oracle 11g开始,修改用户名就比较方便了,直接如下:
SYS@book> alter system set "_enable_rename_user" = true scope=memory;
alter system set "_enable_rename_user" = true scope=memory
                 *
ERROR at line 1:
ORA-02096: specified initialization parameter is not modifiable with this option
--//必须修改spfile,重启才生效.先尝试不修改参数的情况.
SYS@book> alter user sss rename to ttt identified by ttt;
alter user sss rename to ttt identified by ttt
               *
ERROR at line 1:
ORA-00922: missing or invalid option
2.修改参数重启再测试:
SYS@book> alter system set "_enable_rename_user" = true scope=spfile ;
System altered.
--//重启库,考虑到重启库后应用直接连进来,可以使用 restrict重启实例.
SYS@book> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@book> startup restrict
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.
SYS@book> alter user sss rename to ttt identified by ttt;
User altered.
--//OK修改成功.
3.再次重启,修改回来看看.
SYS@book> startup
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.
--//打开另外会话使用ttt用户登录:
TTT@book> select * from dual ;
D
-
X
SYS@book> alter user ttt rename to sss identified by sss;
alter user ttt rename to sss identified by sss
               *
ERROR at line 1:
ORA-00922: missing or invalid option
--//可以发现有ttt用登录是无法修改的.退出以上会话再测试看看!!
SYS@book> alter system flush shared_pool ;
System altered.
SYS@book> alter user ttt rename to sss identified by sss;
alter user ttt rename to sss identified by sss
               *
ERROR at line 1:
ORA-00922: missing or invalid option
--//实际上只能在restrict模式下修改:
SYS@book> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@book> startup restrict
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.
SYS@book> alter user ttt rename to sss identified by sss;
User altered.
4.还原:
SYS@book> alter system reset "_enable_rename_user";
System altered.
5.总结:
--//方便谈不上,只不过提供一种方式修改用户名.而且必须重启数据库在restrict模式下完成操作.

转载于:https://www.cnblogs.com/lfree/p/7088430.html

你可能感兴趣的文章
通过 U 盘启动重装 macOS 系统
查看>>
百度员工离职总结:如何做个好员工?
查看>>
苹果地图(MKmap)获得附近的信息
查看>>
Red Hat Enterprise Linux Server release 6.3下Nagios平台的搭建
查看>>
Docker 1.12 实战 (三)容器部署
查看>>
JVM系列:jinfo命令详解
查看>>
iOS开发那些事-关于性能优化–选择nib还是故事板的讨论
查看>>
你觉得当你老了以后,最后悔的会是什么?
查看>>
Android 热修复原理
查看>>
nginx,apache,mysql,php=namp配置始末
查看>>
vsftpd不支持目录软链接的解决办法
查看>>
Java中byte与16进制字符串的互转
查看>>
解决Windows下修改环境变量后需重启才能生效的问题(转)
查看>>
我的友情链接
查看>>
Linux中变量$#,$@,$0,$1,$2,$*,$$,$?的含义
查看>>
网盘的另类玩法——命令行
查看>>
C++:一段代码,了解拷贝构造函数、move构造函数、拷贝赋值函数、move赋值函数、右值引用...
查看>>
linux下连接github并进行提交
查看>>
IdentityServer4 实现 OpenID Connect 和 OAuth 2.0
查看>>
【Java ThreadLocal的使用】
查看>>