OracleEXP和IMP用法和介绍
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。1、Export/Import的用处
Oracle Export/Import工具用于在数据库之间传递数据。
Export从数据库中导出数据到dump文件中
Import从dump文件中到入数据导数据库中
下面是一般使用他们的情况
(1)、两个数据库之间传送数据
同一个版本的oracle Server之间
不同版本的oracle Server之间
同种OS之间
不同种OS之间
(2)、用于数据库的备份和恢复
(3)、从一个SCHEMA传送到另一个SCHEMA
(4)、从一个TABLESPACE传送到另一个TABLESPACE
2、DUMP文件
EXPORT到出的是二进制格式的文件,不可以手工编辑,否则会损坏数据。
该文件在ORACLE支持的任何平台上都是一样的格式,可以在各平台上通用。
DUMP文件在IMPORT时采用向上兼容方式,就是说ORALCE7的DUMP文件可以导入
到ORACLE8中,但是版本相差很大的版本之间可能有问题。
3、EXPORT/IMPORT过程
EXPORT导出的DUMP文件包含两种基本类型的数据
- DDL (Data Dictionary Language)
- Data
DUMP文件包含所有重新创建Data Dictionary的DDL语句,基本上是可以读的格式
。
但是应该注意的是,千万不要用文本编辑器编辑之,oracle说不支持这样做的。
下面列出的是DUMP文件中包括的ORACLE对象,分为TABLE/USER/FULL方式,有些对
象
只是在FULL方式下才有(比如public synonyms, users, roles, rollback segm
ents等)
Table mode User Mode Full Database Mode
---------------------- ---------------------- ----------------------
---
Table definitions Table definitions Table definitions
Table data Table data Table data
Owner's table grants Owner's grants Grants
Owner's table indexes Owner's indexes Indexes
Table constraints Table constraints Table constraints
Table triggers &nbs
[1] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。p; Table triggers All triggers[2] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。[3] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。; System audit options[4] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。 3. Users 16. Refresh Groups[5] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。p; 23. Stored Procedures[6] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。下被误解。事实上,COMPRESS是改变STORAGE参数INITIAL的值。比如:[NextPage]
[7] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。缓冲区的大小
备份例子1:导出备份数据
#!/bin/bash
#=============================================#
# &n
[8] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。bsp; 如果脚本用于crontab,下面Oracle环境变量必须设置 #BACKUPDIR=/oradata/backup; export BACKUPDIR
USER_PASSWD=dbuser/oracle
RESULTFILE=/export/home/oracle/log/result.log
cd $BACKUPDIR
[NextPage]
exp $USER_PASSWD log=$(date '+%Y%m%d').log file=$(date '+%Y%m%d').dmp owner=dbuser
buffer=4096000 rows=n
if [ $? != 0 ]
then
echo "`date` backup exp fail" >> $RESULTFILE
exit
fi
rm -f tables.txt
sqlplus -s $USER_PASSWD /null
set heading off;
set term off;
set echo off;
set pagesize 0;
set linesize 1000;
set trimspool on;
set trimout on;
set feedback off;
set colsep |;
spool tables.txt;
select table_name from user_tables;
spool off;
exit;
EOF
for table in $(cat tables.txt)
do
exp $USER_PASSWD log=${table}_$(date '+%Y%m%d').log file
=${table}_$(date '+%Y%m%d').dmp tables=$table direct=y
if [ $? != 0 ]
then
echo "`date` backup exp $table fail" >> $RESULTFILE
exit
fi
done
compress -f *.dmp
echo "`date` backup succeed" >> $RESULTFILE
备份例子2:联机日备份数据
#!/usr/local/bin/bash
first_msg()
{
echo "******************************************************"
echo " "
echo "The batch process BACKUP_DAILY is starting at [ 'date' ]"
echo "Excuting by LogName = [ $LOGNAME ]"
echo " "
}
final_msg()
{
echo " "
echo "The batch process BACKUP_DAILY completed at [ 'date' ]"
echo "Excuting by LogName = [ $LOGNAME ]"
echo ">>>>> Please Make 
[9] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。; Sure That It Has Been Done Successfully, "#********************************
# Main *
#********************************
USER_PASSWD=system/system
ARCHIVE_DEST=/appl/oracle/oradata/orafe/arch
DEVICE=/dev/rmt/ctape1
TRC_FILE=$TRC/Z_JOB_BACKUP_DAILY
TMP_SQL=$TRC/backup_daily_tmp.sql
BACKUP_DEST=${BACKUP_PATH}/$(date '+%Y%m%d')
SUCCESS=0
FAIL=1
first_msg
mkdir -m 777 -p $BACKUP_DEST
if [ ! -d $BACKUP_DEST ]
then
echo "$BACKUP_DEST create fail"
exit
fi
[NextPage]
#*******************************
# backup archive log *
#*******************************
echo "=========================================="
echo "Backup archive log begin on [ 'date' ]"
echo "alter system archive log stop;" > $TMP_SQL
sqlplus -s $USER_PASSWD
if [ $? != 0 ]
then
echo "alter archive log stop fail"
exit
fi
cd $ARCHIVE_DEST
FILE_QT='ls|grep -c "arch*"'
FILE='ls|grep "arch*"'
echo "alter system archive log start;" > $TMP_SQL
sqlplus -s $USER_PASSWD
if [ $? != 0 ]
then
echo "alter archive log start fail"
exit
fi
if [ $FILE_QT != 0 ]
then
mv -f $FILE $BACKUP_DEST
cd $BACKUP_DEST
compress -f *
tar -cvf $DEVICE *
if [ $? != 0 ]
then
echo "tar to tape fail"
exit
fi
fi
echo "Backup archive log end on [ 'date' ]"
echo "=========================================="
final_msg
备份例子3:联机全库备份数据
#!/usr/local/bin/bash
first_msg()
{
echo "******************************************************"
echo " &nbs
[10] ...
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。p; "final_msg()
{
echo " "
echo "The batch process JOB_BACKUP_FULL completed at [ 'date' ]"
echo "Excuting by LogName = [ $LOGNAME ]"
echo ">>>>> Please Make Sure That It Has Been Done Successfully, "
echo ">>>>> Otherwise You Must Re-do It."
echo " "
echo "******************************************************"
}
#**************************
#* backup_begin *
#**************************
backup_begin()
{
echo "alter tablespace $1 begin backup;" > $TMP_SQL
sqlplus -s $USER_PASSWD
if [ $? != 0 ]
then
return $FAIL
fi
return $SUCCESS
}
#**************************
#* backup_end *
#**************************
backup_end()
{
echo "alter tablespace $1 end backup;" > $TMP_SQL
sqlplus -s $USER_PASSWD
if [ $? != 0 ]
then
return $FAIL
fi
return $SUCCESS
}
#********************************
# Main *
#********************************
USER_PASSWD=system/system
BACKUP_DEST=$BACKUP_PATH/full
DEVICE=/dev/rmt/ctape1
BACKUP_CFG=$TRC/backup.cfg
TRC_FILE=$TRC/BACKUP_FULL
TMP_SQL=$TRC/backup_full_tmp.sql
SUCCESS=0
FAIL=1
first_msg
rm -f $BACKUP_CFG
sqlplus -s $USER_PASSWD /null
set heading off;
set term off;
set echo off;
set page
[11]
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。size 0;rm -f $TRC_FILE
if [ ! -f $BACKUP_CFG ]
then
echo "备份配置文件缺失" >$TRC_FILE
echo "$BACKUP_CFG not found"
exit
fi
mkdir -m 777 -p $BACKUP_DEST
if [ ! -d $BACKUP_DEST ]
then
echo "备份目录创建失败" >$TRC_FILE
echo "$BACKUP_DEST create fail"
exit
fi
cd $BACKUP_DEST
rm -f *
#*******************************
# backup control file *
#*******************************
echo "=========================================="
echo "正在备份控制文件" > $TRC_FILE
echo "Backup control begin on [ 'date' ]"
echo "alter database backup controlfile to '$BACKUP_DEST/control.ctl';" > $TMP_SQL
sqlplus -s $USER_PASSWD
if [ $? != 0 ]
then
echo "备份控制文件失败" > $TRC_FILE
echo "Backup control file fail"
exit
fi
echo "Backup control end on [ 'date' ]"
#*******************************
# backup tablespaces *
#*******************************
TABLESPACES='cut -d= -f1 $BACKUP_CFG|uniq'
for tablespace in $TABLESPACES
do
echo "=========================================="
echo "正在备份$tablespace" > $TRC_FILE
echo "Backup $tablespace begin on [ 'date' ]"
backup_begin $tablespace
if [ $? != 0 ]
then
echo "备份$tablespace失败" > $TRC_FILE
echo "Turn on backup option of $tablespace fail"
exit
fi
DATAFILES='awk -v var=$tablespace -F = '$1==var {print $2}' $BACKUP_CFG'
for datafile in $DATAFILES
do
 
[12]
正在看的ORACLE教程是:OracleEXP和IMP用法和介绍。; if [ ! -r $datafile ]#**************************
# tar files *
#**************************
echo "=========================================="
echo "正在备份至磁带" > $TRC_FILE
echo "tar to tape on [ 'date' ]"
cd $BACKUP_DEST
tar -cvf $DEVICE *
if [ $? != 0 ]
then
echo "备份至磁带失败" > $TRC_FILE
echo "tar to tape fail"
exit
fi
echo "tar to tape on [ 'date' ]"
echo "=========================================="
echo "全备份已完成" > $TRC_FILE
final_msg
上一页
[13]