存档

‘Sybase ASE’ 分类的存档,文章数:183

当master设备文件正在被二进制编辑器修改时,数据库服务器不能正确读取文件报错:

00:00000:00000:2009/12/14 17:21:11.79 kernel  dopen: open 'D:\sybase\data\master.dat', No error

错误日志中仅仅有这么一条(ase15.0.3esd2#).

每次启动的时候老是报00:00000:00011:2009/12/14 17:26:02.50 server  Error: 12315, Severity: 21, State: 1
00:00000:00011:2009/12/14 17:26:02.50 server  Corrupt page, Internal error: Mismatch between tail timestamp '0b7b' and the low two bytes of timestamp in the page header 'c9d3' while accessing page '2291' of object '3' in database '1'. Please contact Sybase Technical Support.类似的错误,一个一个的修改很麻烦。

启动时打开flag=3607,所有数据库均处于bypass mode。这是截断master的日志报错

1> dump tran master with no_log
2> go
Msg 4237, Level 16, State 1:
Line 1:
Cannot dump master database's log as distributed transaction resolution is not complete ye
t. Please retry later.
1> dump tran master with truncate_only
2> go
Msg 4237, Level 16, State 1:
Line 1:
Cannot dump master database's log as distributed transaction resolution is not complete ye
t. Please retry later.

即使对master数据库进行全备也不能截断日志。

dbcc checkdb(master),dbcc checktable(sysobjects),dbcc checktable(syslogs)等等之后。重启sybase就能够正常启动了。

————————————————————————————————————
——— 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
——— 转载务必注明原始出处 : http://www.dbainfo.net
——— 关键字: ASE 15.0.3 时间戳 二进制  修复 master 设备文件
————————————————————————————————————

此方法有一定的风险,请做好备份。you do it at your own risk!

以前的版本为:
Adaptive Server Enterprise/15.0.3/EBF 16550 ESD#1/P/NT (IX86)/Windows 2003/ase1503/2680/32-bit/OPT/Thu Mar 05 00:21:40 2009
在用mon表的时候报:NT storage access violation in omni_closetable destroyRemoteAccess. 怀疑是bug562998 。

于是打了ebf16738补丁。打补丁的过程和初次安装的过程一样只是wizard显示ASE15.0.3ESD#2,没有新建任何服务就选择完成了。
但是启动数据库的时候报错,很让人崩溃。难道我升级的方法有问题?

启动错误信息如下:

00:00000:00000:2009/12/14 14:55:34.59 kernel  engine 0, os pid 2404  online
00:00000:00000:2009/12/14 14:55:34.59 server  No active traceflags
00:00000:00001:2009/12/14 14:55:34.59 kernel  libomni1 - Component Integration Services: using 'Sybase Client-Library/15.0/P-EBF16074 ESD #15/PC Intel/BUILD1500-111/OPT/Thu Jul 31 20:59:50 2008'
00:00000:00001:2009/12/14 14:55:34.59 server  Opening Master Database ...
00:00000:00001:2009/12/14 14:55:34.71 server  Loading ASE's default sort order and character set
00:00000:00001:2009/12/14 14:55:34.73 server  Recovering database 'master'.
00:00000:00001:2009/12/14 14:55:34.75 server  Started estimating recovery log boundaries for database 'master'.
00:00000:00001:2009/12/14 14:55:34.75 server  Database 'master', checkpoint=(3779,8), first=(3779, 8), last=(3779, 31).
00:00000:00001:2009/12/14 14:55:34.75 server  Completed estimating recovery log boundaries for database 'master'.
00:00000:00001:2009/12/14 14:55:34.75 server  Started ANALYSIS pass for database 'master'.
00:00000:00001:2009/12/14 14:55:34.75 server  Completed ANALYSIS pass for database 'master'.
00:00000:00001:2009/12/14 14:55:34.75 server  Log contains all committed transactions until 2009/12/14 14:42:57.56 for database master.
00:00000:00001:2009/12/14 14:55:34.75 server  Started REDO pass for database 'master'. The total number of log records to process is 24.
00:00000:00001:2009/12/14 14:55:34.78 server  Error: 3474, Severity: 21, State: 1
00:00000:00001:2009/12/14 14:55:34.78 server  During redo the page timestamp value is less than old timestamp from log. Page #=348, object id = 37, page timestamp=0000 00000b20. Log old timestamp=0000 0000dbc2. Log record marker = (3779, 12).
00:00000:00001:2009/12/14 14:55:34.78 server  Cannot recover the master database, exiting.
00:00000:00001:2009/12/14 14:55:34.78 kernel  ueshutdown: exiting

又启动了一次,同样的错误信息。日志的意思是当前时间戳比日志中的时间要小,正常的应该为0000 0000dbc2,而redo中的时间戳为:0000 00000b20。以前日志都记录到(3779, 12).页面上了,升级后不知道什么原因却记到348页面上了?

原因没有搞清楚,但是sybase数据库不能用了。以前研究并且实现了对sybase日志设备的解析工作。通过修改设备文件修改一下时间戳看看能不能奏效吧?

用二进制工具打开master设备文件,根据错误信息中的可疑页号348定位到1433600(350*4096,@@maxpagesize=4096),找到

时间戳0000 00000b20将其修改为0000 0000dbc2。让咱们也来欺骗一下sybase服务器。^_^

0015E000 | 5C 01 00 00 00 00 00 00 5A 01 00 00 25 00 00 00 | \.......Z...%...
0015E010 | 20 0B 00 00 45 00 00 04 00 00 F7 09 02 08 02 00 |  ...E..........
0015E020 | 13 00 02 01 45 00 00 00 00 00 00 00 02 A8 01 4C | ....E.........L
0015E030 | 01 00 00 17 00 1C 70 65 72 63 65 6E 74 20 64 61 | ......percent da
0015E040 | 74 61 62 61 73 65 20 66 6F 72 20 68 69 73 74 6F | tabase for histo
0015E050 | 72 79 02 0E 00 02 AA 01 4C 01 00 00 19 00 1B 70 | ry.....L......p
0015E060 | 65 72 63 65 6E 74 20 64 61 74 61 62 61 73 65 20 | ercent database 
0015E070 | 66 6F 72 20 6F 75 74 70 75 74 02 0E 00 02 A9 01 | for output.....
0015E080 | 4C 01 00 00 18 00 14 70 65 72 63 65 6E 74 20 68 | L......percent h
0015E090 | 69 73 74 6F 72 79 20 66 72 65 65 02 0E 00 02 AB | istory free....

上红色的 20 0B  改为C2 DB 后,启动sybase服务器,成功!日志如下:

00:00000:00001:2009/12/14 15:27:44.29 server  Opening Master Database ...
00:00000:00001:2009/12/14 15:27:44.39 server  Loading ASE's default sort order and character set
00:00000:00001:2009/12/14 15:27:44.40 server  Recovering database 'master'.
00:00000:00001:2009/12/14 15:27:44.40 server  Started estimating recovery log boundaries for database 'master'.
00:00000:00001:2009/12/14 15:27:44.42 server  Database 'master', checkpoint=(3779, 8), first=(3779, 8), last=(3779, 31).
00:00000:00001:2009/12/14 15:27:44.42 server  Completed estimating recovery log boundaries for database 'master'.
00:00000:00001:2009/12/14 15:27:44.42 server  Started ANALYSIS pass for database 'master'.
00:00000:00001:2009/12/14 15:27:44.42 server  Completed ANALYSIS pass for database 'master'.
00:00000:00001:2009/12/14 15:27:44.42 server  Log contains all committed transactions until 2009/12/14 14:42:57.56 for database master.
00:00000:00001:2009/12/14 15:27:44.42 server  Started REDO pass for database 'master'. The total number of log records to process is 24.
00:00000:00001:2009/12/14 15:27:44.46 server  Redo pass of recovery has processed 2 committed and 0 aborted transactions.
00:00000:00001:2009/12/14 15:27:44.46 server  Completed REDO pass for database 'master'.
00:00000:00001:2009/12/14 15:27:44.48 server  Recovery of database 'master' will undo incomplete nested top actions.
00:00000:00001:2009/12/14 15:27:44.48 server  Started recovery checkpoint for database 'master'.
00:00000:00001:2009/12/14 15:27:44.53 server  Completed recovery checkpoint for database 'master'.
00:00000:00001:2009/12/14 15:27:44.53 server  Started filling free space info for database 'master'.
00:00000:00001:2009/12/14 15:27:44.65 server  Completed filling free space info for database 'master'.
00:00000:00001:2009/12/14 15:27:44.65 server  Started cleaning up the default data cache for database 'master'.
00:00000:00001:2009/12/14 15:27:44.67 server  Completed cleaning up the default data cache for database 'master'.
00:00000:00001:2009/12/14 15:27:44.75 server  Checking external objects.
00:00000:00001:2009/12/14 15:27:45.26 server  Database 'master' is now online.

呵呵,问题解决了。出现该问题的原因还未搞清楚!

————————————————————————————————————
——— 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
——— 转载务必注明原始出处 : http://www.dbainfo.net
——— 关键字: ASE 15.0.3 ESD#2 补丁 二进制 设备 dat
————————————————————————————————————

前些天,培训的sybase工程师留下了试用版的powerdesigner12.5,现在适用期限到了。在网上找到两种破解方法。

第一种用破解文件:

1.安装软件后,解压破解压缩包,将pdflm12.dll复制到PD 安装目录下。

2打开PowerDesigner,菜单Tools -> License Parameters..

3.选择Standalone Seat - Local License

4导入license.lic即可破解。

详细请参考:

http://blog.csdn.net/gangqinjiawang/archive/2009/07/15/4349093.aspx

第二种修改dll文件(一个很牛的方法):

在PowerDesigner安装目录下,找到pdflm12.dll,用记事本或其它编辑工具打开,显示的应该是一些二进制的内容.找到83 C4 14 8B 85 E4 FE FF FF,把这一段改成:83 C4 14 33 C0 90 90 90 90.重新打开PowerDesigner,会发现已可以正式使用.PS:本人的是版本12,测试可行,其它版本没有测试过.不知道是否可行.

我在12.5版本上测试能够使用。但是,感觉启动PD的时间很长。不知道这是否和破解有关。还有一网友说用了一段时间就不能用了。不知道自己是否能遇到该问题?

今天下午在shutdown数据库服务器的时候,只有两个isql连接。在其中一个isql连接上发命令 shutdown后然后退出了另一个会话。

一直报SHUTDOWN is waiting for 5 process(es) to complete.的错误,一直一直写。我看了一下。所有的系统进程都处于sleep状态,包括发shutdown命令的进程。在errorlog中没有任何信息。通过sp_who查看到进程里面有DEADLOCK TUNE,HOUSEHOLDER,JOB SCHEDULER等;发送shutdown命令的进程好像在执行checkpoint。不知道为什么?

最后通过另一个session中强制关闭数据库才算完事。shutdown with nowait. 感觉很奇怪!

ASE版本15.0.3/esd#1,网上说好像有一个是:562998 - NT storage access violation in omni_closetable destroyRemoteAccess

我的确遇到了这个bug在使用mon表的时候!

感觉sybase升级到了15.0版本了怎么系统还不是很稳定?

————————————————————————————————————
——— 本文为andkylee个人原创,请在尊重作者劳动成果的前提下进行转载;
——— 转载务必注明原始出处 : http://www.dbainfo.net
——— 关键字: ASE 15.0.3 shutdown 升级 补丁
————————————————————————————————————

已在solaris10,ASE12.5.2下用资源文件resource_files新建了一个4k的sybase服务器。测试该方法通过!
不过在windows下没有这个命令srvbuildres,相类似的命令工具为sybatch,况且windows下还要配置注册表信息才能启动服务除非你想每次都通过RUN_servername来启动!

本指南实际为本人两篇文章的合集,分为安装和迁移两大部分

第一部分:在无GUI环境下安装sybase for linux 12.5.0.1

通常我们建立sybase for linux数据库服务器的时候,都是执行asecfg来建立数据
库,但是这种方式是需要在
服务器上安装X的,即使是通过X FORWARD的方式来操作,也至少需要安装上X
lib。在许多时候下,我们都希望
在服务器上安装的软件包越精越好,即只需要在console环境下就能建立好我们所
需要的服务器。
sybase for linux 就提供了这样一套无需任何X软件包的数据库建立工具---
srvbuildres,它通过读取资源文件
来完成基于console的数据库建立工作。

一 安装rpm包
rpm -ivh --nodeps <rpm包名>

二 激活sybase帐号
passwd sybase

三 设置内核参数
echo $( expr <你的内存容量(以MB为单位)> \* 1024 \* 1024 ) >
/proc/sys/kernel/shmmax
echo "kernel.shmmax = "$( expr <你的内存容量(以MB为单位)> \* 1024 \*
1024 ) >> /etc/sysctl.conf
echo "本机ip hostname" >> /etc/hosts

四 创建数据库服务器和备份服务器
以sybase帐号登录
cp ~/ASE/init/sample_resource_files/srvbuild.adaptive_server.rs ~/server.rs
cp ~/ASE/init/sample_resource_files/srvbuild.backup_server.rs ~/backup.rs
编辑 server.rs

sybinit.release_directory: USE_DEFAULT
sybinit.product: sqlsrv
sqlsrv.server_name: kbibm_ase <--- 填入你所准备起的数据库服务器名称, 这里是我的数据库服务器名字
sqlsrv.new_config: yes
sqlsrv.do_add_server: yes
sqlsrv.network_protocol_list: TCP
sqlsrv.network_hostname_list: <--- 填入数据库服务器所在主机的主机名
sqlsrv.network_port_list: <---端口号
sqlsrv.server_page_size: USE_DEFAULT
sqlsrv.force_buildmaster: no
sqlsrv.master_device_physical_name: /opt/sybase-12.5/data/master.dat
<--- 设定master文件所在位置
sqlsrv.master_device_size: 100 <--- size以MB为单位,这里建立100MB大小的
设备文件。
sqlsrv.master_database_size: 90 〈--- master_database 的size 至少要小于
master_device 7MB,所以这里填90MB
sqlsrv.errorlog: USE_DEFAULT
sqlsrv.do_upgrade: no
sqlsrv.sybsystemprocs_device_physical_name:
/opt/sybase-12.5/data/systemprocs.dat
sqlsrv.sybsystemprocs_device_size: 200 <--- 建立200MB大小的systemprocs设
备文件
sqlsrv.sybsystemprocs_database_size: 200
sqlsrv.sybsystemdb_device_physical_name:
/opt/sybase-12.5/data/sybsystemdb.dat
sqlsrv.sybsystemdb_device_size: 200 <--- 建立200MB大小的sybsystempdb设备文件
sqlsrv.sybsystemdb_database_size: 200
sqlsrv.default_backup_server: kbibm_bak <--- 填入你所准备建立的备份数据库名

备份服务器的rs文件也按此方式进行修改

五 执行srvbuildres来建立数据库
$SYBASE/ASE/bin/srvbuildres -s $SYBASE -r <rs文件>

六 建立sqlloc.rs来设置本地化
sybinit.release_directory: USE_DEFAULT
sqlsrv.server_name: kbibm_ase
sqlsrv.sa_login: sa
sqlsrv.sa_password: serverj
sqlsrv.default_language: us_english
sqlsrv.language_install_list: us_english
sqlsrv.language_remove_list: USE_DEFAULT
sqlsrv.default_characterset: cp850
sqlsrv.characterset_install_list: cp850
sqlsrv.characterset_remove_list: USE_DEFAULT
sqlsrv.sort_order: binary

执行$SYBASE/ASE/bin/sqlloc sqlloc.rs 设置locale

七 由于/etc/init.d/sybase中有两处存在bug,所以我们要修改它
将SYBASE_ASE=`basename $SYBASE/ASE*` 改为 SYBASE_ASE=`basename $SYBASE/ASE`
将SYBASE_OCS=`basename $SYBASE/OCS*` 改为 SYBASE_OCS=`basename $SYBASE/OCS`
否则将不能正常启动sybase

八 /etc/init.d/sybase restart

现在我们就可以用 isql -U sa -P -S <数据库服务器名> 登录进去了。

以上步骤在redhat 7.3 上操作通过。

SYBASE ASE12.5以上版本升级到ASE15的第三种办法

    SYBASE公司的产品Adapter Server目前最新的版本是ASE15.0.2,如何将原有的ASE12.5上的数据库升级到ASE15上?以前常用的方法有如下两种:
    1.upgrade
    2.dump/load
以上两种办法的具体实现方式可参考相关资料,ASE15目前提供了第三种升级的办法,主要是将数据库设备文件使用操作系统命令直接拷贝到升级的新平台。这种办法应该是速度最快的一种,而且Adapter Server的down机时间最短。但前提条件是源和目标均为同种操作系统平台,源和目标server页大小、语言和字符集均要相同,其中源必须是ASE12.5以上的版本。本文具体介绍第三种升级的办法。

假设源Adapter Server名为ase125, 目标Adapter Server名为ase15。可以分别在不同机器上 ,也可以在同一台机器上。
具体升级实现步骤如下:
1.在源Adapter Server上查找数据库所在的设备情况,记住设备逻辑名和所在物理位置。
H:\>isql -Usa -P -Sase125 -w2000
1> sp_helpdb testdb
2> go
1> sp_helpdevice dev1
2> go
1> sp_helpdevice log1
2> go
……
dev1  /data/dev1.dat
log1  /data/log1.dat
……
2.在源Adapter Server上静默数据库,产生一个清单。静默后的数据库就只能提供查询不能增/改/删了
H:\>isql -Usa -P -Sase125 -w2000
1>quiesce database for_upgrd hold testdb for external dump
2>to “/data/testdb_manifest.mfst” with override
3>go

3.将三个文件(/data/dev1.dat、/data/log1.dat、/data/testdb_manifest.mfst)用操作系统命令拷到目标机器(如拷入“/opt/”下)。如果源和目标在同一台机器上,该步不用。

4.现在在源Adapter Server上可以取消静默或直接删除源Adapter Server了。如果源和目标在同一台NT机器上的话,在保留三个文件的基础上可卸载ASE125后,再安装新的ASE15
H:\>isql -Usa -P -Sase125 -w2000
1>quiesce database for_upgrd release
2>go

5.以后的操作都在目标server上,先登记清单,后映射设备,注意设备逻辑名必须与源server一致,物理路径可不同。
H:\>isql -Usa -P -Sase15 -w2000
1>mount database all from “/opt/ testdb_manifest.mfst” with listonly
2>go
1>mount database all from “/opt/ testdb_manifest.mfst” using
2>“/opt/dev1.dat” = “dev1” ,
3>“/opt/log1.dat” =“log1”
4>go
1>use testdb
2>go

6.至此我们就完成了将ASE12.5升级到ASE15的工作。在系统空闲时还可以进行一些后续工作,如:重建索引、更新统计值、dbcc检查等。

这种办法除了可用于升级,还可用于单个数据库在相同操作系统平台下的不同Adapter Server之间迁移。

一个sybase工程师提供的方法!

本文介绍我遇到的将tempdb从master设备上移走时出现的逻辑页面读取错误问题的解决方法。

sybase版本为:Adaptive Server Enterprise/15.0.3/EBF 16550 ESD#1/P/NT (IX86)/Windows 2003/ase1        503/2680/32-bit/OPT/Thu Mar 05 00:21:40 2009

开始时tempdb在master和tempdbdev两个设备上都放置数据和日志,如下:

1> select *from  sysusages
2> where dbid =2
3> go
 dbid   segmap      lstart      size        vstart      pad    unreservedpgs
         crdate                     vdevno
 ------ ----------- ----------- ----------- ----------- ------ -------------
         -------------------------- -----------
      2           7           0        1536       16388   NULL           694
                Dec  2 2009  6:58PM           0
      2           7        1536       25600           0   NULL         25500
                Dec  2 2009  7:01PM           2

由上可见,ASE15版本中默认给临时数据库在tempdbdev设备分配了100m的空间,比起12版本中默认的3M大多了!

为了减少存取系统表时对I/O资源的争夺,将tempdb从master设备上分离出来。

从网上可以找到方法:

sp_dropsegment "default",tempdb,master

sp_dropsegment "system",tempdb,master

sp_dopsegment "logsegment",tempdb,master

我使用的方法是直接删除sysusages表中临时数据库使用的空间分配信息。

1> begin tran
2> go
1> delete from sysusages
2> where dbid = 2 and size =1536
3> go
(1 row affected)
1> select * from sysusages
2> where dbid =2
3> go
 dbid   segmap      lstart      size        vstart      pad    unreservedpgs
         crdate                     vdevno
 ------ ----------- ----------- ----------- ----------- ------ -------------
         -------------------------- -----------
      2           7        1536       25600           0   NULL         25500
                Dec  2 2009  7:01PM           2

(1 row affected)
1> update sysusages
2> set lstart=0
3> where dbid = 2
4> go
(1 row affected)
1> select * from sysusages
2> go
 dbid   segmap      lstart      size        vstart      pad    unreservedpgs
         crdate                     vdevno
 ------ ----------- ----------- ----------- ----------- ------ -------------
         -------------------------- -----------
      1           7           0        6656           4   NULL          4200
                Dec  2 2009  6:58PM           0
      3           7           0        1536       13316   NULL           694
                Dec  2 2009  6:58PM           0
  31513           7           0        1536       19460   NULL           654
                Dec  2 2009  6:58PM           0
  31514           7           0       35840           0   NULL         12240
                Dec  2 2009  6:59PM           1
      2           7           0       25600           0   NULL         25500
                Dec  2 2009  7:01PM           2
  31513           7        1536        1536           0   NULL          1530
                Dec  2 2009  7:01PM           3
  31515           7           0       19200           0   NULL         14410
                Dec  2 2009  7:03PM           4
      4           3           0       76800           0   NULL         75656
                Dec  7 2009  2:28PM           5
      4           4       76800       25600           0   NULL         25500
                Dec  7 2009  2:28PM           6

(9 rows affected)

1> select * into tempdb.dbo.#lzf
2> from sysobjects
3> go
Msg 2762, Level 16, State 3:
Server 'TEST', Line 1:
The 'CREATE TABLE' command is not allowed within a multi-statement transaction
in the 'tempdb' database.
1> commit    (此时已经提交了事务,对sysusages的修改生效!)

关于BCP工具的使用,介绍三个方面的东西

1.命令及参数;

2.出现的问题及解决方法;

3.分析bcp出来的文件结构。

----------------------------------------------------------------------------------------------------------

第一:BCP命令参数

bcp version 11.0.x

function:

Copies a database table to or from an operating system file in a userspecified format.


Syntax:

bcp  [[database_name.]owner.]table_name {in | out}
datafile

[-m maxerrors] [-f formatfile] [-e errfile]

[-F firstrow] [-L lastrow] [-b batchsize]

[-n] [-c] [-t field_terminator] [-r row_terminator]

[-U username] [-P password] [-I sqlini_file]

[-S server] [-a display_charset]
[-q datafile_charset] [-z language] [-v]

[-A packet_size] [-J client_charset]

[-T text_or_image_size] [-E] [-N] [-X]

[-y sybase_dir]

Parameters:

database_name – is optional if the table being copied is in your default database. Otherwise, specify a database name.

owner – is optional if you or the Database Owner own the table being copied. If you do not specify an owner, bcp first looks for a table of that name owned by you. Then it looks for one owned by the Database Owner. If another user owns the table, you must specify the owner’s name or the command fails.

table_name – is the name of the database table to copy. The table name cannot be a Transact-SQL reserved word.

in | out – is the direction of the copy.
in

indicates a copy from a file into the database table;
out

indicates a copy to a file from the database table.

datafile – is the full path name of an operating system file. The path name can be from 1–255 characters in length.

-m max_errors – is the maximum number of nonfatal errors permitted before bcp aborts the copy. bcp discards each row that it cannot insert (due to a data conversion error, or an attempt to insert a null value into a column that does not allow them), counting eachrejected row as one error. If you do not include this option, bcp uses a default value of 10.

 

 

 

-f format_file – is the full path name of a file with stored responses from a previous use of bcp on the same table. After you answer the bcp format questions, bcp asks if you want to save your answers in a format file; creation of the format file is optional. The default file name is bcp.fmt. The bcp program can refer to a format file when copying data, so that you do not have to duplicate your previous format responses interactively. Use this option only when you previously created a format file that you want to use now for a copy in or out. If this option is not used, bcp queries you for format information interactively.
 

 

-e errfile – is the full path name of an error file where bcp stores any rows that it was unable to transfer from the file to the database.Error messages from the bcp program appear on your terminal. bcp creates an error file only when you specify this option. If you specify this option, and bcp does not encounter any nonfatal errors, it does not create the error file.

-F firstrow – is the number of the first row to copy (default is the first row).

-L lastrow – is the number of the last row to copy (default is the last row).

 

-b batchsize – is the number of rows per serial batch of data copied (the default is to copy all the rows in one batch). Each batch is a transaction that is committed at the end of the batch. Batching applies only when bulk copying in; it has no effect on bulk copying out.

-n – performs the copy operation using native (operating system) formats. This option does not prompt for each field. Files in native data format are not human-readable.

-c – performs the copy operation with char datatype as the default.Use this format if you are sharing data between platforms. This option does not prompt for each field; it uses char as the default storage type, no prefixes, \t (tab) as the default field terminator, and \n (newline) as the default row terminator.

-t field_terminator – specifies the default field terminator.

-r row_terminator – specifies the default row terminator.

Note:

When specifying terminators from the command line with the -t or -r option, escape characters that have special significance to the Windows NT Command Prompt shell (see example 1 on page 1-11). Either place a backslash in front of the special character or enclose it in quotes. This is not necessary when bcp prompts you (interactive mode).

-U username – specifies a SQL Server login name. If you do not specify username, bcp uses value of the USERNAME environment variable (the current user’s operating system login name, not the Sybase user name and login).

-P password – specifies a SQL Server password. If you do not specify -P password, bcp prompts for a password. If your password is NULL, place the -P flag at the end of the command line by itself.

-I sqlini_file – specifies the name and location of the interfaces file (sql.ini) to search when connecting to SQL Server. If you do not specify -I, bcp looks for a file named sql.ini in the ini subdirectory of your Sybase release directory.

-S server – specifies the name of the SQL Server to connect to. If you specify -S with no argument, bcp uses the server specified by the DSQUERY environment variable.

-a display_charset – runs bcp from a terminal where the character set differs from that of the machine on which bcp is running. (See the System Administration Guide for more information about changing character sets.) -a in conjunction with -J specifies the character set translation file (.xlt file) required for the conversion. Use –a without -J only if the client character set is the same as the default character set.

-q datafile_charset – runs bcp to copy character data to or from a file system that uses a character set different from the client character set. -q in conjunction with -J specifies the character set translation file (.xlt file) required for the conversion. In Japanese language environments, the -q flag translates Hankaku Katakana (half-width characters) into Zenkaku Katakana (full-width characters). Use with the argument “zenkaku” and with the -J flag to indicate the client’s Japanese character set (sjis or eucjis). The zenkaku.xlt file was designed totranslate only from terminal display to SQL Server, not from SQL Server to the terminal.

Note:

The ascii_7 character set is compatible with all character sets. If either the SQL Server’s or client’s character set is set to ascii_7, any 7-bit ASCII character is allowed to pass between client and server unaltered. Other characters produce conversion errors. Character set conversion issues are covered more thoroughly in the System Administration Guide.

 

-z language – is the official name of an alternate language that the server uses to display bcp prompts and messages. Without the –z flag, bcp uses the server’s default language. You can add languages to a SQL Server during installation or add them afterward with the langinstall utility or the stored procedure sp_addlanguage.
 

 

-v – displays the version number of bcp and a copyright message and returns to the operating system.

-A packet_size – specifies the network packet size to use for this bcp session. For example: bcp -A 2048 sets the packet size to 2048 bytes for this bcp session. size must be between the values of the default network packet size and max network packet size configuration parameters, one-third the size of the additional network memory configuration parameter, and a multiple of 512. To improve the performance of large bulk copy operations, use network packet sizes that are larger than the default.

-J client_charset – specifies the character set to use on the client. bcp uses a filter to convert input between client_charset and the SQL Server character set. -J client_charset requests that SQL Server convert to and from client_charset, the character set used on the client. -J with no argument sets character set conversion to NULL. No conversion takes place. Use this parameter if the client and server use the same character set.The default may not necessarily be the character set that the client is using. See the System Administration Guide for more information about character sets and the associated flags.

-T text_or_image_size – specifies in bytes the maximum length of text or image data that SQL Server sends. The default is 32K. If a text or image field is larger than the value of -T or the default, bcp does not send the overflow.

-E – explicitly specifies the value of a table’s IDENTITY column. By default, when you bulk copy data into a table with an IDENTITY column, the host file must contain a placeholder for the IDENTITY column (a value of 0 is recommended). The server assigns the row a unique, sequential IDENTITY column value, as bcp inserts each row into the table. If the number of inserted rows exceeds the maximum possible IDENTITY column value, SQL Server returns an error message. To use an explicit IDENTITY column value from the host file for each row, specify the -E flag when copying data into a table. The -E option has no effect on bulk copying out.

 

-N – skips the IDENTITY column. Use this option when you copy data in, if your host data file does not include a placeholder for the IDENTITY column values, or when you copy data out and you do not want to include the IDENTITY column information in the host file

 

-X – when connecting to the server, bcp initiates the login with clientside password encryption. bcp (the client) specifies to the server that password encryption is desired. The server sends back an encryption key, which bcp uses to encrypt your password, and theserver uses the key to authenticate your password when it arrives. If bcp crashes, the system creates a core file that contains your password. If you did not use the encryption option, the password appears in plain text in the file. If you used the encryption option, your password is not readable.

-y sybase_dir – specifies a Sybase directory other than the default Sybase release directory.

 

第二:出现的问题及解决方法