Print service provided by iDogiCat: http://www.idogicat.com/
home logo





Home > IT > Database > Sybase Frequently Used Commands

Sybase Frequently Used Commands

Exporting & Importing Data

using bcp to export and import data:


bcp [[<db_name>.]<owner>.]<table_name> {in|out} <data_file_name> -U<user> [-P<password>] -S<db_server> {-n|-c [-t<field_terminator>] [-r<row_terminator>]

Native format:

Use '-n' option. This should not be combined with '-t' or '-r'. If we copy data from one kind of OS to another (for example, from Windows to Unix), then we should not use this mode.

Character format:

Use '-c' option to write to or read from data file in character format. This makes it possible to copy data from one kind of OS to another.

Using char format, the field and row terminators can also be customized using '-t' and '-r' options:


bcp my_db.me.my_table out datafile.txt -Ume -Ppwd -Smy_server -c -t, -r\\r
bcp my_db.me.my_table out datafile.txt -Ume -Ppwd -Smy_server -c -t; -r\|

Note that in Windows, we don't need to escape characters like '\', so it would be '-r\r' and '-r|'.

use bcp with table/field names in Japanese

export LANG=ja
export LC_ALL=ja
bcp DB_NAME..テーブル1 in my_file.txt -S service_name -U the_user -P the_pwd -c -t, -e bcp_error.log
bcp DB_NAME.dbo.テーブル2 out my_file.txt -Jeucjis -U the_user -P the_pwd -S service_name -c -t, -r\\n

Note that the 'dbo' can be omitted.