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

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

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

--//昨天看了链接,提到修改用户名:

--//自己也测试看看.

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模式下完成操作.

转载地址:http://ugkpa.baihongyu.com/

你可能感兴趣的文章
android 圆角编写(懒得去找,写给自己看的)
查看>>
chrome 搜索 jsonView
查看>>
chrome浏览器:chrome 69 恢复默认UI
查看>>
Irony - 一个 .NET 语言实现工具包
查看>>
Java之Static静态修饰符详解
查看>>
修改weblogic部署的应用名称
查看>>
aaronyang的百度地图API之LBS云与.NET开发 Javascript API 2.0【基本地图的操作】
查看>>
Java Nio 多线程网络下载
查看>>
C++不让程序一闪而过
查看>>
C# 中的枚举类型 enum (属于值类型)
查看>>
[Debug] Use Snippets to Store Behaviors in Chrome DevTools
查看>>
【Java面试题】3 Java的"=="和equals方法究竟有什么区别?简单解释,很清楚
查看>>
通用性好的win2003序列号: (推荐先用这个里面的)
查看>>
Chromium Embedded Framework中文文档 (升级到最新的Chrome)
查看>>
WPF Command CanExecute 的执行逻辑
查看>>
更为快捷的Excel操作方式 快捷键 Alt使用技巧动画图解
查看>>
程序员们最易犯的10种错误
查看>>
面试必考题!你知道CSS实现水平垂直居中的第10种方式吗?
查看>>
超多惊喜!苹果 iPhone8 最新渲染图曝光
查看>>
你想要不想要?OPPO R11将搭配前后2000万像素镜头!
查看>>