打印本文 打印本文 关闭窗口 关闭窗口
usage of bcp command.(快来看)。
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3547  更新时间:2009/4/22 23:09:59  文章录入:mintao  责任编辑:mintao

这个是我从Manual上copy下来的,希望对大家有用。

bcp
Description 
  Copies  a database to or from an operating system file in a user-specified format.
Syntax 
bcp [[database_name.]owner.][view_name | table_name    [:partition_id]] {in | out} datafile[-c] [-E] [-n] [-X]
 [-a display_charset]
 [-A size]
 [-b batchsize]
 [-e errfile]
 [-f formatfile]
 [-F firstrow]
 [-g id_start_value]
 [-I interfaces_file]
 [-J client_charset]
 [-L lastrow]
 [-m maxerrors]
 [-P password]
 [-q datafile_charset]
 [-r row_terminator]
 [-R remote_server_principal]
 [-S server]
 [-t field_terminator]
 [-T text_or_image_size]
 [-U username]
 [-z language]
or
bcp -v
Parameters 
database_name
is optional if the table being copied is in your  default database or in master. Otherwise, you  must specify a database name.
owner
is optional if you or the Database Owner owns the  table being copied. If you do not specify an owner, bcp looks  first for a table of that name that you own, and then looks for  one owned by the Database Owner. If another user owns the table,  you must specify the owner name or the command fails.
view_name
is the name of the view you are copying out.
table_name
is the name of the database table to copy.
Partition number partition_number does  not exist in table table_name.
partition_id
is the identifier of the partition into which to  copy.
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 or view.
datafile
is the full path name of an operating system file.  The path name can be from 1 to 255 characters in length.
-c 
performs the copy operation with char datatype  as the default. This parameter 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.
-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, bcp assigns  each row a temporary IDENTITY column value of 0. As bcp inserts  each row into the table, the server assigns the row a unique, sequential  IDENTITY column value, beginning with the value 1. If you specify  the -E flag when copying data into a table, bcp prompts  you to enter an explicit IDENTITY column value for each row. If  the number of inserted rows exceeds the maximum possible IDENTITY  column value, Adaptive Server returns an error.
By default, when you bulk copy data from a table with an IDENTITY column, bcp excludes  all information about the column from the output file. If you specify  the -E flag, bcp copies the  existing IDENTITY column values into the output file.
You cannot use the -E and -g flags  together.
-n 
performs the copy operation using native (operating  system) formats. Specifying the -n parameter  means bcp will not prompt for each field. Files in  native data format are not human-readable.
Warning! Do not use bcp in native format  for data recovery or salvage or to resolve an emergency situation.  Do not use bcp in native format to transport data  between different hardware platforms, different operating systems,  or different major releases of Adaptive Server. Do not use field terminators  (-t) or row terminators (-r)  with bcp in native format. Results are unpredictable  and data could become corrupted. Using bcp in  native format can create flat files that cannot be reloaded into Adaptive Server and  it may be impossible to recover the data. If you are unable to re-run bcp in  character format (for example, a table was truncated or dropped,  hardware damage occurred, a database was dropped, and so on) the  data will be unrecoverable.
-X
specifies that, in this connection to the server,  the application initiates the login with client-side 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 the server uses the key to authenticate  your password when it arrives.
-a display_charset
allows you to run bcp from a  terminal where the character set differs from that of the machine  on which bcp is running. Use -a in  conjunction with -J to specify 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.
The following error message will appear if the character translation  file(s) named with the -a parameter is missing,  or you mistype the name(s): 
Error in  attempting to determine the size of a pair of translation tables.:'stat' utility  failed.
-A size
specifies the network packet size to use for this bcp session.  For example: 
bcp pubs2..titles out table_out  -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 maximum  network packet size configuration variables, and it must  be a multiple of 512.
Use larger-than-default network packet sizes to improve the  performance of large bulk-copy operations.
-b batchsize
is the number of rows per batch of data copied  (the default is to copy all the rows in one batch). Batching

[1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口