gpt4 book ai didi

mysql - 为什么 Table Import 显示错误 1366,Data looks good

转载 作者:太空宇宙 更新时间:2023-11-03 11:26:09 25 4
gpt4 key购买 nike

我从我的工作台中的 View 导出数据以将此数据上传到我在其他数据库上的新表中,但是当我尝试上传此数据时,出现以下错误:

- Row import failed with error: ("Incorrect integer value: '' for column 'id_genero_musical' at row 1", 1366

我所做的是将此值“”更改为 NULL,但是当我将 NULL 值放入 CSV 文件时,它显示:

- Row import failed with error: ("Incorrect integer value: 'NULL' for column 'id_genero_musical' at row 1", 1366

但是我的文件没有引号,我的文件如下:

4,"Cultura",NULL,"FM",102.5,0,NULL,NULL,"http://www.cultura.fm.br/","",NULL,16,"PR",2969,"Cultura",5,NULL
6,"Abdallah",NULL,"FM",104.1,55,NULL,NULL,"http://www.abdallahfm.com.br/","http://server3.webradios.com.br:9338/9338","57dbac33ef411",16,"PR",2911,"Abdallah",5,3
7,"Aline",NULL,"FM",93.7,0,NULL,NULL,"http://www.alinefm.com.br","http://controleflash.omegasistemas.net:8356/;stream.mp3","57dbac367dbbc",16,"PR",3147,"Aline",5,3
8,"Amiga",NULL,"FM",101.3,40,NULL,NULL,"http://www.amiga101.com.br","http://stream4.painelvox.com.br:7052","57dbac337965d",16,"PR",2878,"Amiga",5,3
9,"Caiuá",NULL,"FM",103.5,80,NULL,NULL,"http://www.caiuafm.com.br/","http://stream1.painelvox.com.br:6946/","57dbac352b125",16,"PR",3015,"Caiuá",5,1

我在 MySQL Workbench 上使用导入按钮,数据库是 MariaDB

我花了 2 或 3 天试图解决这个问题,但没有成功,请帮助我。

谢谢大家!!

编辑 1:

Workbench 假设 NULL 值是一个文本,而不是 NULL 值,如果它是一个真正的 NULL 值,我该如何处理以导入 CSV 文件?

最佳答案

我不使用 mysql workbench 导入向导,因为坦率地说它很讨厌,而且我从来没有找到一种方法来设置 OPTIONALLY ENCLOSED BY 或 LINES TERMINATED BY。您可能想尝试使用

LOCAL INFILE <filepath> INTO TABLE <schema.table> 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
(id_emissora, ds_nome, id_tipo_emissora, ds_modulacao, ds_frequencia, nr_alcance,
perc_alcance, qt_habitantes_alcance, ds_url, ds_streaming, ds_id_anatel, id_uf, ds_uf, id_municipio, ds_municipio, id_regiao, id_genero_musical);

如果您使用的是 nix 框,请注意编码问题 LINES TERMINATED BY '\r\n' 可能需要修改为 LINES TERMINATED BY '\n'

这个负载在 win10 和 mariadb 上对我来说工作正常

关于mysql - 为什么 Table Import 显示错误 1366,Data looks good,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54217288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com