您好,欢迎访问一九零五行业门户网

Oracle 中如何更改用户名

实际工作中,有时候需要修改用户名,而通常的做法是exp imp这样的方式,而如果数据量大的话exp imp的方式会很浪费时间,所以下面写上如何通
实际工作中,,有时候需要修改用户名,而通常的做法是exp imp这样的方式,而如果数据量大的话exp imp的方式会很浪费时间,所以下面写上如何通过修改oracle基表的方式来修改用户名。
-- 直接修改底层表user$更改用户名(该方法在oracle9i中测试通过)
sql> update user$ set where user#=91;
已更新 1 行。
sql> commit;
提交完成。
sql> alter system checkpoint;
系统已更改。
sql> alter user tt identified by values '294ce6e7131dd890';
alter user tt identified by values '294ce6e7131dd890'
*
error 位于第 1 行:
ora-01918: 用户'tt'不存在
强制 oracle 读取实际数据,而不是读取缓存
sql> alter system flush shared_pool;
系统已更改。
sql> alter user tt identified by values '294ce6e7131dd890';
用户已更改。
测试连接
sql> conn tt/tt
已连接。
sql> select * from tab;
tname tabtype clusterid
------------------------------ ------- ----------
test_tt table
sql> conn / as sysdba
已连接。
sql> show user
user 为sys
sql> shutdown immediate
数据库已经关闭。
已经卸载数据库。
oracle 例程已经关闭。
sql> startup
oracle 例程已经启动。
......
数据库装载完毕。
数据库已经打开。
可以看出没有再恢复为test
sql> select user#,name,password from user$ where user#=91;
user# name password
---------- ------------------------------ ----------------
91 tt 294ce6e7131dd890
sql> conn tt/tt
已连接。
查看数据对象
sql> select * from tab;
tname tabtype clusterid
------------------------------ ------- ----------
test_tt table
sql> select * from test_tt;
a
-
a
对象权限依然有效
sql> select * from test1.test1_tt;
a
-
a
系统权限依然有效
sql> create table kk as select * from test1.test1_tt;
表已创建。
sql> select * from tab;
tname tabtype clusterid
------------------------------ ------- ----------
kk table
test_tt table
sql> conn / as sysdba
已连接。
sql> show user
user 为sys
--drop user 也没有问题
sql> drop user tt cascade;
用户已丢弃
sql> drop user test1 cascade;
用户已丢弃
其它类似信息

推荐信息