MySql insert bit using tab delimited -


itemprop = "text">

I used a tab delimited file to insert data into a MySql database

I got 0 and 1 as a value but when I insert data into the database using its downconversion command 0 to 1

  data load local infile. Table membership in 'c: /membership.txt';   

The structure of the table is the result of a column on each result as value 1 in each row. Create a table subscription (MemberShipId not weakened AUTO_INCREMENT, StartDate datetime not empty, datetime not empty on ENDDATE, AgeGroup tinyint, newsletter bit, charity decimal (7.2), favorite varchar (50), comments varchar ( 200), MemberId not blank int, primary key (int membership), contract FKMMER forward for (member ED) reference member (Member Ed));

Sample input is

  1 2012-01-01 2012-01-01 0 0 \ N \ N 1 2012-01-01 2012- 01-01 1 0 \ N \ N 2 3 2012-01-01 2012-01-01 1 0 \ N \ N 3 4 2012-01-01 2012-01-01 1 0 \ N \ N 4 5 2012-01 -01 2012-01-01 0 0 \ N \ N 5 6 2012-01-01 2012-01-01 0 0 \ N \ N 6    

When the CSV file is imported, it seems that your value is being quoted extensively as a string after 5.0.3 in a MySQL When using the BIT type, this is in the form of a little field (for example '11001'), boolean form Not as doors 1/0. The string value '0' and '1' seem to be interpreted as non-empty data, and you just do not get a 0.

Instead, you can use a TINYINT (1) type or its option Boolean , which will support numeric values ​​1 or 0. Create a table code (Use the tinnetate (1) for membership entry not empty, AUTO_INCREMENT, start date, datetime faucet, end date datetime-time null, edge group tinty, / * bullion, or bullion * / newsletter tinet ( 1), Use of donation amount 7,2), Choice Shaw Verma (50), Comments Announcement (200), Member Inline not listed, Primary (Member ID), Contract FKMMR Forward Keye (Member ID) Reference Member (Member D));

Comments