MYSQL加载数据填充
我在mysql中使用加载数据填充。在我的输入文件中,我有“x”字符,但我必须将其作为NULL保存到数据库中。我怎么做MYSQL加载数据填充,mysql,null,load-data-infile,Mysql,Null,Load Data Infile,我在mysql中使用加载数据填充。在我的输入文件中,我有“x”字符,但我必须将其作为NULL保存到数据库中。我怎么做 load data infile... into table ... fields terminated by... lines terminated by ... ( my_field... ) set my_field = if(my_field = 'x', null, my_field); 多亏了佩卡 多亏了pekka,它非常有用,但它首先将x指定为date,然后
load data infile...
into table ...
fields terminated by...
lines terminated by ...
(
my_field...
)
set
my_field = if(my_field = 'x', null, my_field);
多亏了佩卡
多亏了pekka,它非常有用,但它首先将x指定为date,然后更改为null。这违反了“日期不能是‘x’”的规定,嗯??在加载时,它会检查my_字段的值。如果它是“x”,它将写入一个空值,否则它将写入原始值。哦,它是一个日期字段-如果您之前提到过,它将非常有用!它非常有用,但它首先将x指定为date,然后更改为null。这违反了“日期不能是‘x’”的规定,嗯??在加载时,它会检查my_字段的值。如果它是“x”,它将写入一个空值,否则它将写入原始值。哦,它是一个日期字段-如果您之前提到过,它将非常有用!
load data infile...
into table ...
fields terminated by...
lines terminated by ...
(
@var...
)
set
my_field = if(@var = 'x', null, @var);