Usage of bcp

Source: Internet
Author: User
Tags character set execution one table sybase sybase database backup

BCP is a tool that Sybase company provides for data backup at the level of database tables.
Typically stored in the installed ASE or open Client Bin directory.
The previous ASE,BCP storage directory for the 12 version is $SYBASE/bin
12 Version (including 12 version) to store the directory after the $SYBASE/ocs-12_x/bin
Where $sybase is the Sybase installation directory, 12_x represents version 12.0, 12.5, shown as 12_0 or 12_5

The executable file name is called bcp. Exe
The list of parameters is as follows: (Available bcp–)
USAGE:BCP [[database_name.] Owner.] Table_name[:slice_number] {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 interfaces_file] [-s server]
[-a display_charset] [-q datafile_charset] [-z language] [-v]
[-A  Packet size] [-j client character set]
[-t text or image size]  [-e] [-g id_start_value] [-n] [-x]
[-m labelname labelvalue] [- Labeled]
[-k keytab_file] [-r remote_server_principal]
[-v [security_options]]  [-z security_mechanism] [-q]

The usual data backup format is:
BCP dbname ... TableName out C:\temp\filename-usa-ppassword–sservername–c
Can.
Where –u is the Sybase login name, –p after the Sybase login password, –s is the Sybase service name, and the –C representative uses the visible text method to export the data
If you only need to replace out with in for data recovery.

You can generate an execution script that exports data from all tables in one database at a time.
Edit one of the following text file file name examples are bcpscript:
Use dbname to select the database to which you want to export data
Go
Select ' bcp dbname. ' + name + ' out c:\temp\ ' + name + '-usa-p-ssybcdsrv-c ' from sysobjects where type = ' U ' in Sysobje The table with type U in the CTS system table is the user table and the system table is S.
Go

Executed in the following format:
Isql–usa–ppassword–sservername–i Bcpscript–o Bcpout.bat
I parameter after the input file, o parameter file for the input file after the execution of the output file.
After execution, you can get a batch file with a suffix named BAT (Generate a Shell file under UNIX and change the appropriate execution permissions) to execute directly. That is, the corresponding data file is exported under the specified directory. The data for one table is a file. If you are under UNIX, you do not use a bat suffix.

If you need to revert back to the database for the backed-up data file, simply change the out parameter in the bcp command in the previous procedure to the in parameter.
Note: It's a good idea to do some testing before you do the official data.
In addition, if you are involved in the use of bcp for character set changes, you can use the –J charset parameter to
For specific instructions on tools such as BCP, see Sybase related documentation.

There are several steps you can take to work with a system transplant:
1. Install the new environment hardware environment, including network, hard disk condition;
2. Installation of the new environment of the operating system, including service packs;
3. Install the same version of Sybase database products, including patches;
4. Add database users, equipment and other related information, should be consistent with the old system
5. Creation of a new system database;
6. Using your own table script or generating DDL functionality from Sybase Central, export the build table script in the old system to generate the tables in the database. It is best to separate the script from the table to create the constraints on the tables (primary key, foreign key, etc.), first on the table without constraints, after the data import, plus.;
7. BCP out of the old system data, according to the method mentioned above;
8. Run scripts to create other objects, including indexes, primary keys, foreign keys and stored procedures, triggers, defaults, etc.
9. Make changes to the table structure that needs to be changed in the new system, or add a new table;
10. Test the application system is working properly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.