简体   繁体   中英

First load of a txt file using the sql command line

I work locally with WAMPSERVER2.5

I built my dadabase on OpenOfficeCalc: db.txt

- Character set: Unicode (UTF-8)
- Field separator: ,
- Text separator: "

I want to import "db.txt" in a table named "db_pma" which is in the database named "hct" (in PhpMyAdmin)

"db.txt" contains 2 fields:

- string_field (character string, max:30)
- numeric_field (sample: 5862314523685.256325632)

Questions:

1) Do I need to first create in PhpMyAdmin the structure of the table ("db_pma") which will contain the data?

2) I tried this code to import "db.txt"

  mysql -h localhost -u root
    LOAD DATA LOCAL INFILE 'db.txt'
    INTO  TABLE dp_pma
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY 'AUTO'; 

It doesn't work. Could you help me?

请改用LINES TERMINATED BY '\\r\\n' (对于 Windows)或LINES TERMINATED BY '\\n' (对于 Linux)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM