Import Export all oracle database

#EXPORT

source /home/oracle/.bash_profile
sqlplus / as sysdba

#path file in /home/oracle folder
CREATE OR REPLACE DIRECTORY test_dir AS '/home/oracle/orabak/';
GRANT READ, WRITE ON DIRECTORY test_dir TO USER_SCHEMA;

#exit sqlplus

#export data
expdp USER_SCHEMA/password@SID_SERVICE_NAME schemas=SCOTT directory=TEST_DIR dumpfile=SCOTT.dmp logfile=expdpSCOTT.log

################################################################################
#IMPORT

source /home/oracle/.bash_profile
sqlplus / as sysdba

#path file in /home/oracle folder
CREATE OR REPLACE DIRECTORY test_dir AS '/home/oracle/orabak/';
GRANT READ, WRITE ON DIRECTORY test_dir TO USER_SCHEMA;

#to import go to create USER_SCHEMA match in new db
impdp USER_SCHEMA/new_password@SID_SERVICE_NAME  schemas=SCOTT directory=TEST_DIR dumpfile=SCOTT.dmp logfile=impdpSCOTT.log

Creat readOnly user

source /home/oracle/.bash_profile
sqlplus / as sysdba

alter session set "_ORACLE_SCRIPT"=true;
create user READUSER identified by password;
grant create session, select any table, select any dictionary to READUSER;


Last updated