< postgresql>将数据从临时表插入带有JSON值的主表
我正在使用PostgreSQL,并且正在尝试从临时表中插入主表中。
在临时表中,我有2列:MD5SUM(VARCHAR和NOT NULL)和值(JSON数据)。
我尝试了这些查询:
insert into main_table SELECT distinct * FROM temp ON CONFLICT (md5sum) DO NOTHING;
但是
insert into main_table(md5sum, values)
select distinct md5sum, values
from main_table
where not exists (
select md5sum, scores
from temp
where
temp.md5sum = main_table.md5sum);
我一直遇到此错误:无法识别JSON类型的相等性操作员。
如何解决此错误?
I am using postgresql and I am trying to insert into the main table from a temporary table.
In the temp table I have 2 columns: md5sum (varchar and not null) and values (json data).
I tried these queries:
insert into main_table SELECT distinct * FROM temp ON CONFLICT (md5sum) DO NOTHING;
and
insert into main_table(md5sum, values)
select distinct md5sum, values
from main_table
where not exists (
select md5sum, scores
from temp
where
temp.md5sum = main_table.md5sum);
But I keep getting this error: could not identify an equality operator for type json.
How to solve this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在JSON类型上做不同的事情。解决方法是将其扔给JSONB。如果以下对您有用,请尝试。
You cannot do distinct on json type. The workaround is to cast it to jsonb. Try if the following works for you.