How to export and import scripts in oracle
Export
Export all tables under a specified user
# Environment variable setting export ORACLE_SID = bdyzexport ORACLE_BASE =/u01/oracle11g_R2export ORACLE_HOME = $ ORACLE_BASE/11 gexport LD_LIBRARY_PATH = $ ORACLE_HOME/libexport NLS_LANG = "simplified chinese" _ china. zhs16gbk; export PATH = $ PATH: $ ORACLE_HOME/binrq = $ (date + % Y % m % d) user_name = 'lltf' user _ passwd = 'lltf _ 000000' bak _ dir =/u01/oradata/$ {user_name}/$ rqif [! -S $ bak_dir]; then mkdir-p $ bak_dirfi # create a backup directory and authorize the user sqlplus/as sysdba <EOFdrop directory dump_dir; create directory dump_dir as '$ {bak_dir}'; grant read, write on directory dump_dir to $ {user_name }; quitEOFexpdp $ {user_name}/$ {user_passwd} directory = dump_dir dumpfile =$ {user_name} _ % U. dmp schemas =$ {user_name} logfile =$ {user
Export a specified table under a specified user
#!/bin/shexport ORACLE_SID=ldb1export ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/11.2.0/db_1export PATH=${PATH}:$ORACLE_HOME/binbak_dir='/home/oracle/lxm/meituan/data_of_tables_need_compare_module'user_name='ldb'user_passwd='ldb'sqlplus / as sysdba <<EOFdrop directory dump_dir;create directory dump_dir as '${bak_dir}';grant read,write on directory dump_dir to ${user_name};quitEOFexpdp ${user_name}/${user_passwd} TABLES=${user_name}.t_sof_subscriber,${user_name}.t_subscriber_import_task,${user_name}.t_as,${user_name}.t_subscriber,${user_name}.T_SMB_MSISDN directory=dump_dir dumpfile=${user_name}_%U.dmp compression=ALL filesize=1g parallel=8 Import
#! /Bin/sh .~ /. Bash_profilebak_dir = '/home/oracle/lxm/meituan/data_of_tables_need_compare_module' exp _ user_name = 'ldb' exp _ tablespace = 'ldb _ data' exp _ index_tablespace = 'ldb _ Index' current _ tablespace = 'users' user _ name = 'test' user _ passwd = 'test' sqlplus/as sysdba <EOFdrop directory exp_dir; create directory exp_dir as '$ {bak_dir}'; grant read, write on directory exp_dir to $ {user_name }; quitEOFimpdp $ {user_name}/$ {user_passwd} PARALLEL = 8 cluster = no dumpfile =$ {exp_user_name} _ % U. dmp directory = exp_dir REMAP_TABLESPACE =$ {exp_tablespace }:: {current_tablespace}, $ {exp_index_tablespace }:: {current_tablespace} REMAP_SCHEMA =$ {exp_user_name }: $ {user_name} TABLE_EXISTS_ACTION = truncate # The error code $ {exp_index_tablespace }:: {user_name} # If the data table space (index tablespace) of the source and target databases is not added) similarly, you do not need to use REMAP_TABLESPACE for ing;