可在 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
首先感谢诸位对此文的兴趣,现解释如下: 一、导出用户数据库中的表,将其置入文件 tables.tmp 中。
isql -Usa -Ppas -Sserver -otables.tmp <<-EOF USE database_name GO SELECT name FROM sysobjects WHERE type='U' ORDER BY name GO exit EOF
二、编辑 tables.tmp ,因 tables.tmp 中首两行和末三行, 是我们不要的东西。前次的有小小错,现更正如下:
vi tables.tmp </dev/null :1,2 d (删首两行) :$ (到末行) :-2,. d (删末三行) :1,$ <<< (清各行左侧空格,即各行顶左。当然一个 < 也够用,1,$ 也可换成 % ) : x EOF
至如 <使它们不在屏上显示,哈哈、、、就用它了。 找本书看看,再在 SHELL 下,带 <键入上述脚本,你就会有收获的。EOF 可用其他字母,但前后必须一致。
三、导出用户数据库各表中的数据
total=`cat tables.tmp|wc -l` (总表数) current=0 (当前的第 n 张表) for table in `cat tables.tmp` (将文件 tables.tmp 中的表名依次赋给 table) 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
没有相关教程
|