问题描述
我有一个庞大的数据库,我想使用 BCP 将其转储出来,然后将其加载到其他地方.我对 BCP 的 Sybase 版本(更熟悉 MSSQL 版本)进行了大量研究,我了解了如何使用导入文件,但我一生都无法弄清楚如何创建一个.
I have a huge database which I want to dump out using BCP and then load it up elsewhere. I have done quite a bit of research on the Sybase version of BCP (being more familiar with the MSSQL one) and I see how to USE an Import file but I can't figure out for the life of me how to create one.
我目前正在使我的 Sybase bcp 输出数据文件,如下所示:
I am currently making my Sybase bcp out files of data like this:
bcp mytester.dbo.XTABLE out XTABLE.bcp -U sa -P mypass -T -n
并尝试像这样导入它们:
and trying to import them back in like this:
bcp mytester.dbo.XTABLE in XTABLE.bcp -E -n -S Sybase_157 -U sa -P SyAdmin
现在,无论表是否具有标识,IN 部分都会给我一个关于 IDENTITY_INSERT 的错误:
Right now, the IN part gives me an error about IDENTITY_INSERT regardless of if the table has an identity or not:
服务器消息:Sybase157 - 消息 7756,级别 16,状态 1:无法使用表 'mytester.dbo.XTABLE' 的 'SET IDENTITY_INSERT' 因为表没有标识属性.
我经常使用此页面上的重要信息来寻求帮助,但这是我第一次提出问题,所以我虚心地请求大家提供任何指导:)
I have often used the great info on this page for help, but this is the first time i've put in a question, so i humbly request any guidance you all can provide :)
推荐答案
在您的 BCP 中,-E
标志告诉 bcp 从输入文件中获取标识列值.我会尝试在没有那个标志的情况下运行它.Sybase 中的 fmt 文件有点挑剔,如果可能的话,我会尽量避免.因此,只要您的系统之间的架构相同,以下命令就应该起作用:
In your BCP in, the -E
flag tells bcp to take identity column values from the input file. I would try running it without that flag. fmt files in Sybase are a bit finicky, and I would try to avoid if possible. So as long as your schemas are the same between your systems the following command should work:
bcp mytester.dbo.XTABLE in XTABLE.bcp -n -S Sybase_157 -U sa -P SyAdmin
此外,您的 bcp 输出上的 -T
标志似乎很奇怪.我知道 SQLServer -T 是一个安全设置,但在 Sybase 中它表示文本或图像列的最大大小,后跟一个数字..例如 -T 32000
(将是 32Kbytes)
Also, the -T
flag on your bcp out seems odd. I know SQLServer -T is a security setting, but in Sybase it indicates the max size of a text or image column, and is followed by a number..e.g -T 32000
(would be 32Kbytes)
但是要回答标题中的问题,如果您以交互方式运行 bcp(不指定 -c
、-n
或 -f
) 它将遍历每一列,提示输入信息.最后它会询问您是否要创建格式文件,并允许您指定文件名.
But to answer the question in your title, if you run bcp out interactively (without specifying -c
,-n
, or -f
) it will step through each column, prompting for information. At the end it will ask if you want to create a format file, and allow you to specify the name of the file.
作为参考,这里是语法和可用标志:http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc30191.1550/html/utility/X14951.htm
For reference, here is the syntax and available flags:http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc30191.1550/html/utility/X14951.htm
这篇关于如何生成Sybase BCP Fmt文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!