1

Is it possible to use ENUM together with a LOAND DATA?

I need to check the items at the moment I'm loading the data. I found a way to define these items at the time of creating the table but there is a possibility that some of them will undergo a naming change and as the base is huge it will take a long time to do this...

This is the file I'm trying to load

enter image description here

I'm using the code below to load the data

LOAD DATA LOCAL INFILE 'C:/sql/vendas/teste.txt'
REPLACE
INTO TABLE vds_isiz
FIELDS TERMINATED BY ';'
-- OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
SET
**Produto =ENUM('VIVO ','ZTV'),**
CPFCNPJ = LPAD(CPFCNPJ,11,0)
;

I'm getting the error below exactly on line 9 which is the ENUM

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to 
your MariaDB server version for the right syntax to use near '('VIVO','ZTV'),
 CPFCNPJ = LPAD(CPFCNPJ,11,0)' at line 9    0.000 sec
1
  • Your syntax is invalid. Investigate correct syntax in Reference Manual. PS. ENUM value can be loaded without problems.
    – Akina
    Commented Feb 5, 2022 at 18:54

1 Answer 1

0

ENUM('VIVO ','ZTV') belongs in the CREATE TABLE

"VIVO" (or "ZTV") belongs in the file -- as you have it. And, yes, the LOAD DATA needs OPTIONALLY ENCLOSED BY '\"' because of the quotes in the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.