MySQL Bulk Import class Mysqlbulkloader

Source: Internet
Author: User

In the corresponding Sqlbuckcopy class in MSSQLServer, bulk data is inserted.

In MySQL, the official provided the Mysqlbulkloader parallel tool;

But there is a pit inside, and the concrete pit is null by inserting a null column.

For-input, if the FIELDS ESCAPED BY character is not empty, occurrences of this character is stripped and the following character is Taken literally as part of a field value. Some Two-character sequences that's exceptions, where the first character is the escape character. These sequences is shown in the following table (using for the \ escape character). The rules for NULL handling is described later in this section.

Character Escape Sequence
\0 An ASCII NUL ( X‘00‘ ) character
\b A BACKSPACE character
\n A NewLine (linefeed) character
\r A Carriage return character
\t A tab character.
\Z ASCII (Control+z)
\N Null

In the driver provided by MySql.Data.dll, using the \ n character does not insert a null column. You should use the keyword NULL to represent the empty value.

Tran = conn. BeginTransaction ();                      Mysqlbulkloader bulk = new Mysqlbulkloader (conn)                      {                          fieldterminator = ",",                          fieldquotationcharacter = ' ",                          escapecharacter = ' "',                          LineTerminator = "\ r \ n",                          FileName = Tmppath,                          numberoflinestoskip = 0,                          TableName = table. TableName,                      };                      Bulk. Columns.addrange (table. Columns.cast<datacolumn> (). Select (Colum = Colum. ColumnName). ToArray ());                      Insertcount = bulk. Load ();  

  

Specific information:

Https://dev.mysql.com/doc/connector-net/en/connector-net-programming-bulk-loader.html

Https://dev.mysql.com/doc/refman/5.7/en/load-data.html

http://blog.csdn.net/zhou2s_101216/article/details/50875211

Https://dev.mysql.com/doc/refman/5.7/en/load-data.html

MySQL Bulk Import class Mysqlbulkloader

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.