为什么insert into sheet_sale_detail(company_id, item_id ,flow_id,recent_price_avg) values ('99' ,'54206','15059', '{"avg1": 7, "avg2": 8.5, "avg3": 8.62}') on conflict(company_id,item_id,flow_id) do update set recent_price_avg = '{"avg1": 7, "avg2": 8.5, "avg3": 8.62}'报错ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
时间: 2024-04-12 21:34:47 浏览: 15
这个报错是因为在执行插入操作时,没有找到与 ON CONFLICT 子句中指定的冲突检测条件相匹配的唯一约束或排除约束。
在你的 SQL 语句中,使用了 ON CONFLICT 子句来处理冲突,但是没有指定具体的约束条件。在执行插入操作时,系统需要根据指定的约束条件来确定是否存在冲突。
你可以检查一下表格的结构,确保在 company_id、item_id 和 flow_id 列上存在唯一约束或排除约束。如果不存在,你需要创建一个适当的约束来解决这个问题。
相关问题
insert into tb_books values是什么意思
"insert into tb_books values" 是一个 SQL 语句,用于将数据插入到名为 "tb_books" 的数据库表中。具体来说,"insert into" 是 SQL 插入语句的关键字,"tb_books" 是要插入数据的表名,"values" 是指要插入的具体数据值。例如,以下 SQL 语句会向 "tb_books" 表中插入一条记录,包含 "book_id"、"book_name" 和 "author" 三个字段的值:
```
insert into tb_books (book_id, book_name, author) values (1, 'The Great Gatsby', 'F. Scott Fitzgerald');
```
insert into tb_voucher ( shop_id, title, sub_title, rules, pay_
insert into tb_voucher (shop_id, title, sub_title, rules, pay_amount) values ('店铺ID', '优惠券标题', '副标题', '使用规则', '支付金额');
这是一条SQL语句,用于将数据插入到tb_voucher表中。其中,'店铺ID'表示具体的店铺编号,'优惠券标题'表示优惠券的标题,'副标题'表示优惠券的副标题,'使用规则'表示使用优惠券的规则,'支付金额'表示使用此优惠券需要支付的金额。
通过执行这条SQL语句,我们可以将相关的优惠券信息插入到tb_voucher表中,以便后续使用和查询。具体的值可以根据实际情况进行替换,确保插入的数据准确无误。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)