BCP is generally stored in the BIN directory of the installed ASE or Open Client. For ASE earlier than version 12, the bcp directory is $ SYBASE/bin, and for Versions later than Version 12 (including version 12), the directory is $ SYBASE/OCS-12_x/bin. $ SYBASE is the SYBASE installation directory. 12_x represents versions 12.0 and 12.5 and is displayed as 12_0 or 12_5. the executable file name is bcp. EXE.
The parameter list is as follows:(Available bcp-available)
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_mechanic] [-Q]
Common Data Backup formats:
bcp dbname..tablename out c:\temp\filename -Usa -Ppassword –Sservername –c |
-U indicates the SYBASE logon name,-P indicates the SYBASE logon password,-S indicates the SYBASE service name, and-c indicates that the data is exported using visible text, to recover data, replace out with in.
You can use the following method to generate an execution script that can export data from all tables in a database at a time.
Edit the following text file named bcpscript:
Use dbnameSelect the database to export data
Go
Select 'bcp dbname... '+ name + 'out c: \ temp \' + name + '-Usa-P-Ssybcdsrv-C' from sysobjects where type = 'U'In the sysobjects system table, tables with type U are user tables, and system tables are S)
Go
Run the command in the following format:
Isql-Usa-Ppassword-Sservername-I bcpscript-o bcpout. batAfter the I parameter, It is the input file. After the o parameter, the file is the output file obtained after the input file is executed)
After execution, you can get a batch file with the suffix BAT (a shell file is generated in unix and the corresponding execution permission is changed), which can be executed directly. That is, the corresponding data file is exported under the specified directory. The data of a table is a file. For example, in UNIX, the BAT suffix is not required.
If you need to restore the data files backed up to the database again, you only need to replace the out parameter in the BCP command in the preceding operation steps with the in parameter.
Note: You are advised to perform some tests before performing operations on the official data.
In addition, you can use the-J charset parameter to modify the character set using bcp. For more information about how to use tools such as BCP, see SYBASE.
Perform the following steps for system transplantation:
1. Install the hardware environment of the new environment, including the network and hard disk status;
2. Install the operating system of the new environment, including the Service Pack;
3. Install SYBASE database products of the same version, including patches;
4. Add database users, devices, and other related information, which should be consistent with those in the old system.
5. Create a New System database;
6. use your table script or the DDL generation function in sybase central to export the table creation script in the old system to generate tables in the database. it is best to separate the table creation script from the script that creates table constraints (primary keys, foreign keys, and so on). First, do not create constraints on the table. After the data is imported, Add .;
7. bcp out data in the old system, according to the method mentioned above;
8. run scripts for creating other objects, including indexes, primary keys, foreign keys, stored procedures, triggers, and defaults;
9. modify the structure of the table to be modified in the new system or add a new table;
10. test whether the application system works properly.
- Several configuration problems of Sybase Database
- How does SQL Server access sybase database tables?
- How to Set Sybase user permissions to process Processes