當(dāng)前位置:首頁(yè) > IT技術(shù) > 數(shù)據(jù)庫(kù) > 正文

Oracle 數(shù)據(jù)泵遷移用戶(hù)創(chuàng)建 SQL語(yǔ)句
2021-09-13 10:32:37

在進(jìn)行數(shù)據(jù)泵遷移時(shí),通常是按照用戶(hù)進(jìn)行導(dǎo)入導(dǎo)出,因此需要確認(rèn)當(dāng)前數(shù)據(jù)庫(kù)中存在那些非系統(tǒng)用戶(hù)!

查看數(shù)據(jù)庫(kù)中用戶(hù)狀態(tài)為 OPEN 的用戶(hù):

select username,account_status,created,PROFILE from dba_users where account_status='OPEN' order by created;

通過(guò)上述sql查詢(xún)出的結(jié)果中,根據(jù) created 字段可以篩選掉非系統(tǒng)用戶(hù)!

查看數(shù)據(jù)庫(kù)中的角色:

select * from dba_roles;

創(chuàng)建用戶(hù) SQL:

select 'create user ' || t.username || ' identified by values ' || chr(39) ||
       u.password || chr(39) || ' default tablespace ' ||
       t.default_tablespace || ' profile ' || p.name || ' Temporary TABLESPACE '|| TEMPORARY_TABLESPACE  ||';' create_user_withoutpass
  from dba_users t, sys.user$ u, sys.profname$ p, sys.user_astatus_map m
 where t.user_id = u.user#
   and u.resource$ = p.profile#
   and u.astatus = m.status#
   and t. username in ('需要?jiǎng)?chuàng)建的用戶(hù)名,用逗號(hào)隔開(kāi)');

用戶(hù)授權(quán):

select 'GRANT connect,resource,unlimited tablespace,DBA to ' ||username|| ';' from dba_users where username in ('需要?jiǎng)?chuàng)建的用戶(hù)名,用逗號(hào)隔開(kāi)');

???? 注意:如果是使用expdp,則不需要?jiǎng)?chuàng)建用戶(hù)和授權(quán)!


本次分享到此結(jié)束啦~

如果覺(jué)得文章對(duì)你有幫助,點(diǎn)贊、收藏、關(guān)注、評(píng)論,一鍵四連支持,你的支持就是我創(chuàng)作最大的動(dòng)力。

?? 技術(shù)交流可以 關(guān)注公眾號(hào):Lucifer三思而后行 ??

本文摘自 :https://blog.51cto.com/l

開(kāi)通會(huì)員,享受整站包年服務(wù)立即開(kāi)通 >