2008年7月19日星期六

sybase数据导出导入脚本

可在 sybase 用户下创建,将其命名为 bcpoutdata 。
然后 chmod a+x bcpoutdata
在 sybase 用户下运行 bcpoutdata 即可。
注:
1)将 database_name 改为你的数据库名。
2)将 pas 改为你的 sa 口令。
3)将 server 改为你的 SQL server 名。
4)要导入,将 out 改为 in 即可。
最后提醒你,别忘了要在 sybase 用户下创建一个目录,
把 bcpoutdata 置入其中,再运行。
什麽?你要打包、压缩。
哈,在后面加几条:
tar cvf data.tar *.bcp
compress data.tar
rm *.bcp
愿各位好运

isql -Usa -Ppas -Sserver -otables.tmp <<-EOF
USE database_name
GO
SELECT name FROM sysobjects WHERE type='U' ORDER BY name
GO
exit
EOF
vi tables.tmp <;/dev/null
:1,2 d
:$ d
:1,$ <<<
: x
EOF
total=`cat tables.tmp|wc -l`
current=0
for table in `cat tables.tmp`
do
current=$current+1
echo "*** $current/$total bcpout $table ***"
bcp database_name..$table out $table.bcp -Usa -Ppas -Sserver -Jiso_1 -c
echo "*** $table done ***\n"
done
rm tables.tmp

没有评论: