import text file into mysql workbench?

后端 未结 1 856
渐次进展
渐次进展 2020-12-18 12:58

I was wondering how to import text file into MySQL workbench?

I have a text file delimited by | and the first row are the tables,

FEATUR         


        
相关标签:
1条回答
  • 2020-12-18 13:31

    It's not clear what exactly you intend to achieve, but if you want to import delimited text file into db then you can use LOAD DATA INFILE like this:

    LOAD DATA INFILE '/path/file.txt' 
    INTO TABLE tablename 
    FIELDS TERMINATED BY '|'
    LINES TERMINATED BY '\n'
    IGNORE 1 LINES;
    

    UPDATE:

    First of cause you need to create the table (if it's not done yet) like this:

    CREATE TABLE `tablename` (
      `FEATURE_ID` int(11) unsigned NOT NULL,
      `FEATURE_NAME` varchar(512) DEFAULT NULL,
      `FEATURE_CLASS` varchar(512) DEFAULT NULL,
      PRIMARY KEY (`FEATURE_ID`)
    )
    

    You might need to adjust data types, lengths, and constraints on that table. For example you might not need a PK on that table.

    0 讨论(0)
提交回复
热议问题