十进制(整数)值不正确:''mySQL [英] Incorrect decimal (integer) value: ' ' mySQL

查看:177
本文介绍了十进制(整数)值不正确:''mySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mySQL workbench数据库中,其中一个表具有纬度,经度和区域属性

In mySQL workbench database, one of the tables has latitude, longitude and district attributes

lat:decimal(10,8)

lat: decimal (10,8)

lng:十进制(11,8)

lng: decimal (11,8)

分区:int(4)

我正在尝试将.csv文件中的数据导入此表

I'm trying to import data from .csv file to this table

ERROR 1366: 1366: Incorrect decimal value: '' for column 'lat' at row 1
SQL Statement:
ERROR 1366: 1366: Incorrect integer value: '' for column 'district' at row 1
SQL Statement:
INSERT INTO `db`.`myTable` (`id`, `name_en`, `icon`, `lat`, `lng`, `district`, `city`, `postal_code`)
    VALUES ('686', 'Name',?, '', '', '','1', 'P.O. Box 1111')


推荐答案

您启用了严格的sql模式,并尝试将空字符串('')作为插入中十进制字段的值传递。空字符串是数字字段的无效值,并且在严格的sql模式 mysql中如果您尝试将无效数据插入列中,而不是提供警告并使用特定列的数据类型的默认值(数字列为0),则会生成错误:

You have strict sql mode enabled, and you try to pass an empty string ('') as value for decimal fields in the insert. Empty string is an invalid value for a numeric field and in strict sql mode mysql generates an error if you try to insert an invalid data into a column, rather than providing a warning and use the default value (0 for numeric columns) of the particular column's data type:


严格模式控制MySQL如何处理
数据更改语句(如INSERT或UPDATE)中的无效或缺失值。由于多种原因,值可能是
无效。例如,列可能包含错误的数据
类型,或者可能超出范围。当要插入的新行不包含其定义中没有显式DEFAULT子句的非NULL
列的值时,值缺少
。 (对于
NULL列,如果缺少值,则插入NULL。)严格模式
也会影响DDL语句,例如CREATE TABLE。

Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. (For a NULL column, NULL is inserted if the value is missing.) Strict mode also affects DDL statements such as CREATE TABLE.

如果严格模式不起作用,MySQL会为
无效或缺失值插入调整后的值并产生警告(参见章节
13.7.5.40,显示警告语法)。在严格模式下,您可以通过使用INSERT IGNORE或UPDATE IGNORE来产生此行为。

If strict mode is not in effect, MySQL inserts adjusted values for invalid or missing values and produces warnings (see Section 13.7.5.40, "SHOW WARNINGS Syntax"). In strict mode, you can produce this behavior by using INSERT IGNORE or UPDATE IGNORE.

在启动之前删除会话的严格sql模式导入:

Remove the strict sql mode for the session before starting the import:

SET SESSION sql_mode = ''

这篇关于十进制(整数)值不正确:''mySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆