Import CSV files to Mysql Workbench

Asked

Viewed 361 times

0

I have a file .csv which contains in columns (vertically):

  • Product.1 (line1)
  • Product.2 (Linha2)

But when I do this query:

use test;

LOAD DATA LOCAL INFILE 'local' INTO TABLE tabela1;

Always give me a warning that the kind of attribute of tabela1 is whole.

I have the tabela1 defined with only one attribute - product but every time I type varchar it changes to the whole how I wrote the file? And which options I choose? primary key, null?

  • 1

    put the error technical message there for me to analyze... Even giving the Warning Does it import the file or reject the import? Remember that Warning (warning) is different from error and in theory does not prevent the execution of the command.

  • @Pauloroberto already got it!

  • use test; LOAD LOCAL DATA INFILE'local 'INTO TABLE Tabela1 Fields terminated by ';' Lines terminated by ' r'; ;

  • 1

    my congratulations this evolving fast, put the answer there of how you managed to solve the problem, ie answer your own question in detail so that other people also learn.

1 answer

0


The following code works for Mac, if using Windows put '/n' instead of '/r':

use test; 

LOAD DATA LOCAL INFILE 'local' INTO TABLE tabela1 
fields terminated by ';' 
lines terminated by '\r'; 

;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.