impdp按用戶導入
1、創建該用戶對象所設計到所有表空間
create tablespace tbs_hankey_dat datafile '/opt/oracle/oradata/tbs_hankey.dbf' size 2G; create temporary tablespace tbs_hankey_tmp datafile '/opt/oracle/oradata/tbs_hankey_tmp.dbf' size 2G;
create tablespace tbs_hankey_idx datafile '/opt/oracle/oradata/tbs_hankey_idx.dbf' size 2G;
2、創建用戶
create user hankey identified by "hankey" default tablespace tbs_hankey_dat temporary tablespace tbs_hankey_tmp;
如果需要清理舊用戶的數據,然后導入新數據(生產環境謹慎操作)
su - oracle sqlplus / as sysdba 在執行之前,先斷開數據庫的會話 drop user hankey cascade;
若刪除用戶時顯示用戶占用,請用一下sql查看,然后執行拼接的sql。
select 'alter system kill session '''||sid||','||serial#||''';' from v$session where upper(username)='HANKEY';
3、導入
su - oracle oracle@Hankey:~$ impdp \'/ as sysdba\' DUMPFILE=hankey_202002028.dmp logfile=webcc_sh.log DIRECTORY=DATA_PUMP_DIR transform=oid:n parallel=4
4、使用oracle用戶登錄到終端,加密內置算法(非必須,當前項目正好用到)
su - oracle sqlplus / as sysdba SQL>@?/rdbms/admin/dbmsobtk.sql SQL>grant execute on DBMS_CRYPTO to hankey;
5、重新編譯數據庫對象
sqlplus / as sysdba exec dbms_utility.compile_schema('HANKEY');
6、按用戶收集表的統計信息
exec dbms_stats.gather_schema_stats('HANKEY',estimate_percent=>100,no_invalidate=>DBMS_STATS.AUTO_INVALIDATE,method_opt=>'for all columns size auto',force=>TRUE,cascade=>TRUE,degree=>10);
附:按表收集統計分析
exec dbms_stats.gather_table_stats(ownname => 'HANKEY',tabname => 'T_TEST',CASCADE=>TRUE);