- 论坛徽章:
- 0
|
求教SQL語句,導出一個數據庫所有內容
不嫌弃的话,我给个例子,以前发过的:
#! /bin/csh
source $home/cshrc2
cd
cd tab_load
rm *.data
rm tab_result.sql
dbaccess eomsdb - << EOF
unload to tab_struc.tmp DELIMITER ";"
select "dbschema -d eomsdb -t "||trim(tabname)||" -ss "||trim(tabname)||".txt"
from systables where (tabname not like 'sys%' and tabtype='T');
unload to tab_data.sql DELIMITER ";"
select "unload to "||trim(tabname)||".data select * from "||trim(tabname)
from systables where (tabname not like 'sys%' and tabtype='T');
unload to tab_drp.sql DELIMITER ";"
select "drop table "||trim(tabname)
from systables where (tabname not like 'sys%' and tabtype='T');
unload to tab_data_load.sql DELIMITER ";"
select "load from "||trim(tabname)||".data insert into "||trim(tabname)
from systables where (tabname not like 'sys%' and tabtype='T');
EOF
chmod 777 *.tmp
echo `date`
echo "unloading table struction ..."
tab_struc.tmp >;/tmp/tab_load.log
echo "unloading data to file ..."
dbaccess eomsdb tab_data.sql >;>;/tmp/tab_load.log
cat *.txt >;>; tab_result.sql
rm *.txt
rm *.tmp
#rm tab_data.sql
cd $home
echo "zip the data to tab_load.tar..."
tar cvf tab_load.tar tab_load >;>;/tmp/tab_load.log
set date1=`date '+%m%d%H'` |
|