Loand data com ENUM



  • 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
    


  • 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.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2