0

I am storing the contents of text files in a table

CREATE TABLE Pages
(
ID int(11) unsigned NOT NULL,
Text mediumtext COMPRESSED,
PRIMARY KEY(ID)
) ENGINE=ARIA DEFAULT CHARSET=utf8 COLLATE utf8_general_ci ROW_FORMAT=DYNAMIC

I try to INSERT each file's contents directly via LOAD DATA INFILE

LOAD DATA INFILE 'file.txt' INTO TABLE table 
 FIELDS TERMINATED BY '\0' LINES TERMINATED BY '' (Text) 
 SET ID=$id

The problem is that if I ideally use TERMINATED BY '', it gives the error

You can't use fixed rowlength with BLOBs; please use 'fields terminated by'

I used '\0' assuming the null character does not exist in the text file. Although it works, is there a more standard way to do so?

Googlebot
  • 15,159
  • 44
  • 133
  • 229
  • 1
    If you need to load the whole file and store its complete body into one column in one row then you must use not LOAD DATA statement but common INSERT/UPDATE statement with LOAD_FILE() function in it. – Akina Nov 11 '22 at 05:22
  • @Akina you are absolutely right, that's the correct way to do so. – Googlebot Nov 11 '22 at 05:56

0 Answers0