Oracle創建表空間、用戶並授權腳本及linux系統下expdb、impdb命令表空間複製、遷移

創建表空間

創建時用dba角色登錄,注意修改dbf路徑,表空間ods_test更換成自己想要的表空間

create tablespace ods_test
datafile 'D:\oradata\ods_test.dbf' size 200m
autoextend on  
next 50m maxsize 4096m  
extent management local;

創建用戶

用戶名ods_test和密碼更換成自己想要的用戶和密碼,表空間和上面的對應

create user ods_test identified by odstest123 default tablespace ods_test;

授權

批量替換ods_test爲上面創建的用戶直接執行即可

grant connect,resource to ods_test;
grant create any view to ods_test;
grant debug any procedure to ods_test ;
grant dba to ods_test;
grant select on sys.dba_pending_transactions to ods_test;
grant select on sys.pending_trans$ to ods_test;
grant select on sys.dba_2pc_pending to ods_test;
grant execute on sys.dbms_system to ods_test;

複製表空間、數據遷移

進入linux後輸入命令切換到oracle用戶下,注意,一定要有“-”,否則無法正常使用expdb、impdb命令

su - oracle

導出dmp文件,輸入dba的用戶名密碼,路徑可以爲DATA_PUMP_DIR,此爲oracle的一個常量,最後schemas爲要導出的用戶名,以下命令爲導出miiro用戶下所有的對象

expdp system/passwrod file=miiro.dmp directory=DATA_PUMP_DIR schemas=miiro;

導入數據,注意linux下文件名是區分大小寫的,REMAP_SCHEMA和remap_tablespace是替換原用戶及表空間的命令,冒號前衛source,冒號後衛target

impdp system/password DIRECTORY=DATA_PUMP_DIR DUMPFILE=miiro.dmp REMAP_SCHEMA=miiro:miiro_test remap_tablespace=miiro:miiro_test table_exists_action=replace;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章