11g修改用户名

数据库版本oracle 11203

修改用户名是11g的新功能,测试一下:

隐藏参数_enable_rename_user需要打开才能修改用户名,先查看一下默认的值。默认是false

SQL> SELECT   ksppinm, ksppstvl, ksppdesc
  2  FROM   x$ksppi x, x$ksppcv y
  3  WHERE x.indx = y.indx AND  ksppinm = '_enable_rename_user';

KSPPINM                   KSPPSTVL        KSPPDESC
------------------------- --------------- --------------------------------------------------
_enable_rename_user       FALSE           enable RENAME-clause using ALTER USER statement

 建立一个测试用户yss,目标是将yss改成yys

SQL> grant connect,resource to yss identified by yss;

Grant succeeded.

SQL> 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

隐藏参数_enable_rename_user需要重启instance后才能修改,先在spfile中修改再重新启动。

SQL> 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


SQL>  alter system set "_enable_rename_user" = true scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             167772440 bytes
Database Buffers          138412032 bytes
Redo Buffers                4747264 bytes
Database mounted.
Database opened.

开始修改用户名时出错,按文档需要在startup restrict模式下才能修改。

SQL> alter user yss rename to yys identified by yys;
alter user yss rename to yys identified by yys
               *
ERROR at line 1:
ORA-00922: missing or invalid option

再启后继续测试:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup restrict
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             167772440 bytes
Database Buffers          138412032 bytes
Redo Buffers                4747264 bytes
Database mounted.
Database opened.
SQL>  alter user yss rename to yys identified by yys;

User altered.

更改成功

SQL> conn yss/yss
ERROR:
ORA-01017: invalid username/password; logon denied


Warning: You are no longer connected to ORACLE.
SQL> conn yys/yys
ERROR:
ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege

恢复隐藏参数为false,正常打开数据库:

SQL> alter system set "_enable_rename_user" = false  scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             167772440 bytes
Database Buffers          138412032 bytes
Redo Buffers                4747264 bytes
Database mounted.
Database opened.

SQL> conn yys/yys
Connected.
SQL> select * from dual;

D
-
X

测试结束!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值