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