#!/bin/ksh
###############################################################
## Use : Unload the table data to unl format
## Usage : Put the table names in tables.txt and call the script
###############################################################
############# Usage ##########################
if [ $# -ne 3 ]
then
echo "Usage: $0 username password oracleServiceName"
exit 1
fi
#set the parameters
username=$1
password=$2
servicename=$3
#Check the connection
sqlplus -S ${username}/${password}@${servicename} > connection.log <<EOF
EOF
isError=`grep -i "ERROR" connection.log | wc -l`
#If error exit the script
if [ $isError -ne 0 ]
then
echo "Oracle connection Failed!!! "
cat connection.log
rm -f connection.log
exit 1
fi
### Unload Function #########
unloadData() {
if [ $# -eq 0 ]
then
return
fi
sqlplus -S ${username}/${password}@${servicename} <<EOF >>/dev/null
set head off;
set feed off;
spool on;
spool result.txt;
${1}
spool off;
EOF
#Remove Blank Lines and SQL prompts from the output
awk 'NF!=0 && $0!~/SQL/ { print $0 }' result.txt > queryResult.txt
rm result.txt
return
}
#Check if tables.txt exist or not
if [ ! -f tables.txt ]
then
echo "tables.txt file does not exit. Please put the tablenames in tables.txt"
exit 1
fi
sed -i y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ tables.txt
#Read the Tables
for tablename in `cat tables.txt`
do
#Get the columns
unloadData "select column_name from COLS where table_name = '${tablename}';"
mv queryResult.txt columnName.txt
sqlQuery=""
#For the SQLQuery to unload as unl
for columnname in `cat columnName.txt`
do
if [ "${sqlQuery}x" == "x" ]
then
sqlQuery="select ${columnname}"
else
sqlQuery="${sqlQuery}||'|'||${columnname}"
fi
done
sqlQuery="${sqlQuery} from ${tablename};"
unloadData "${sqlQuery}"
mv queryResult.txt ${tablename}.unl
done
分享到:
相关推荐
15:33:19: [restore_table] Trying to restore data to SYS.TRUNTAB1$$2 15:33:20: [restore_table] Expected Records in this round: 411 15:33:20: [restore_table] 411 records recovered 此处省略N行输出.....
标题:dul无法加载bootstrap实现unload table/user恢复 作者:惜分飞 最近有朋友误操作引起了非常大的事故,差点吃了官司.在做数据库迁移的时候,远程误操作删除了原库的system等几个数据库初始安装的文件,而且该磁盘...
Speed access to data through table and index design Manage files and memory structures for performance and reliability Scale up through partitioning and parallel processing Load and unload data to ...
FROM TABLE TABLE.NAME (COLUMN1 POSITION(*) ,COLUMN2 POSITION(*) ,COLUMN3 POSITION(*) ,COLUMN4 POSITION(*) ,COLUMN5 POSITION(*)) ``` 上述 JCL 脚本中,UNLOAD 命令用于卸载数据到 CSV 文件。DELIMITED 选项...
* Speed access to data through table and index design * Manage files and memory structures for performance and reliability * Scale up through partitioning and parallel processing * Load and unload...
FROM (SELECT tablespace_name, SUM(bytes) / 1024 / 1024 AS total_space FROM dba_data_files GROUP BY tablespace_name) dbf, (SELECT tablespace_name, SUM(bytes) / 1024 / 1024 AS used_space FROM dba_...
### Oracle 10g for Windows 安装与配置详解 #### 一、Oracle 10g for Windows 的安装环境需求 在安装Oracle 10g for Windows之前,确保满足以下环境要求: - **操作系统**: Windows Server 2003 SP2 - **内存**:...
SQL> RMAN> { RUN { UNLOAD DATABASE KEEP DATAFILES; } } ``` ### 3. 创建数据库 (Create Database) 在Oracle中创建数据库涉及多个步骤,包括定义数据文件和日志文件的位置及大小等。示例代码为: ```sql CREATE ...
Oracle SQL 讲义笔记 本资源为 Oracle SQL 讲义,涵盖了 SQL 的基本概念、数据类型、表操作、数据...* UNLOAD 语句:用于将数据从数据库中 unload 到文件中,例如:UNLOAD TABLE dpe_file INTO OUTFILE 'data.txt';
ODU(Oracle Data Unloader)是一款专门用于 Oracle 数据库紧急恢复的软件工具。它可以直接从数据文件中解析和恢复数据,最大限度地保障数据安全。下面是 ODU 在 Oracle 数据库中的应用知识点: ODU 工具的特点 1....
4. 备份表数据:`unload to <File.unl> select * from <Table>`。 5. 恢复表数据:`load from <File.unl> insert into <Table>`。 6. 查看数据库运行状态:`onstat –`检查数据库状态,`onstat –g ses`查看会话。...
oracle-ascii-unload 概述 oracle-ascii-unload是一个Oracle Pro * C程序,用于将Oracle数据库表中的数据有效地卸载到以control-A分隔的定界ASCII文本文件中(也称为^A或\x01或\001 )。 它本身支持DATE,NUMBER,...
sqlplus -s $DB_USER/$DB_PWD@$DB_SERV @unload_oracle.sql ``` 其中 unload_oracle.sql 文件内容为: ``` SET TIME OFF SET ECHO OFF SET HEAD OFF SET NEWPAGE NONE SET HEADING OFF SET SPACE 0 SET PAGESIZE 0...
然后,使用ORACLE_DATAPUMP驱动方式创建一个新的表`t_images_unload`,该表用于存储卸载的数据。其定义如下: ```sql CREATE TABLE t_images_unload ORGANIZATION EXTERNAL ( TYPE oracle_datapump DEFAULT ...
10. **Oracle Function**:Oracle提供了许多内置函数,如TO_DATE, TO_CHAR, NVL等,用于数据转换和处理。 11. **LOAD, UNLOAD指令**:用于导入和导出数据,通常使用SQL*Loader(LOAD)和Export/Import utilities...
首先,我们需要了解Oracle的卸载(UNLOAD)和装载(LOAD)过程。在Oracle中,DBMS_METADATA和DBMS_DATA_PUMP是两个常用的包,用于数据的导出和导入。控制文件(CTL)记录了数据装载的过程,包括数据源、目标、表名等...
例如,`grant read,write on directory unload_dir to` 将授予 unload_dir 目录的读写权限。 输出 ORACLE 查询结果到 TXT 文件需要设置多个参数,包括设置每行的字符数目、每页输出的行数、列的设置、禁止输出列...
在Visual Basic (VB)编程中,`Unload`事件是一个关键的概念,特别是在处理用户界面(User Interface, UI)元素,如窗体(Form)时。这个事件在窗体即将从内存中卸载或者关闭时被触发,是程序员进行清理工作,释放资源或...