gpt4 book ai didi

postgresql - DBeaver 导入 csv 空字符串,因为 NULL 不起作用

转载 作者:行者123 更新时间:2023-12-02 20:23:20 24 4
gpt4 key购买 nike

我有下表 prop_info,其中有对 desp 的外键引用。我正在尝试导入包含这些的 csv 文件

prop_code,prop_name,price
ABC,,1.2,
ABB,Apple,5.0,

CREATE TABLE prop_info (
prop_code CHAR (3) PRIMARY KEY NOT NULL,
prop_name VARCHAR (100) REFERENCES desp (product_name) ON UPDATE CASCADE,
price float NOT NULL
);

CREATE TABLE desp 
(
product_name VARCHAR (100) PRIMARY KEY NOT NULL,
product_desp VARCHAR (100)
);

我尝试使用 DBeaver 上传 CSV,收到此错误:

ERROR: insert or update on table "prop_info" violates foreign key constraint "prop_info_prop_name_fkey"
Detail: Key (prop_name)=() is not present in table "desp".

根据 PostgreSQL,我确实有未加引号的空字符串。

Specifies the string that represents a null value. The default is \N (backslash-N) in text format, and an unquoted empty string in CSV format. You might prefer an empty string even in text format for cases where you don't want to distinguish nulls from empty strings. This option is not allowed when using binary format.

这是我的 DBeaver 的问题吗?需要帮助。

最佳答案

有一个选项Set empty strings to NULL,它在 DBeaver 21.3.4 Community Edition 中对我有用

enter image description here

关于postgresql - DBeaver 导入 csv 空字符串,因为 NULL 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50708436/

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