解决HeidiSQL提示错误:0 rows updated when that should have been 1

场景:在HeidiSQL中点击一个字段值并进行更改,修改完成后点击其他空白处,出现了以下错误提示!

0 rows updated when should have been 1 

本来没在意这个提示,只是偶然更新失败罢了,但后来慢慢注意到,出现这种情况的频率非常高,100%!!!而且更严重的是查询出来的数据是不准确的!因为数据库涉及到很重要的数据,解决问题迫在眉睫了。

我最先意识到可能是数据库的问题,于是重启了数据库服务和HeidiSQL,很不幸。。。失败了

谷歌百度了很久,也去官网查了,都没有找到好的解决方案。

命不该绝啊,就在这样的关键时刻,看到了官网评论区一个大神给别人的回复:(译)数据表没有主键执行更新操作是非常危险的!我赶紧对号入座,果然没有主键,加上主键后果然再也没有提示过了。

虽然问题解决了,但是还是不太明白其中的原理,为啥数据表不设置主外键,或者引索会导致数据操作不安全呢?希望有专业的大佬能帮我解决这个困惑,不胜感激!

To amplify specific rows by selecting dates and keep the amplified rows in the original dataframe in R, you can use the following steps: 1. Load your dataset into R using a data frame. 2. Convert the date column to a date format using `as.Date()`. 3. Use the `subset()` function to select the rows that match your desired date range. 4. Use the `ifelse()` function to amplify the selected rows by a certain factor and keep the original value for the remaining rows. 5. Replace the original value column with the amplified values using the assignment operator. Here's an example code snippet that demonstrates these steps: ```R # Load your dataset into R df <- read.csv("your_data.csv") # Convert the date column to a date format df$date <- as.Date(df$date) # Select the rows that match your desired date range date_range <- df$date >= "2021-01-01" & df$date <= "2021-12-31" # Amplify the selected rows by a factor of 2 and keep the original value for the remaining rows df$value <- ifelse(date_range, df$value * 2, df$value) # View the updated dataframe df ``` In this example, we first load our dataset into R and convert the date column to a date format. We then define a logical vector `date_range` to identify the rows that fall within the date range of January 1st, 2021 to December 31st, 2021. We use the `ifelse()` function to amplify the selected rows by a factor of 2 and keep the original value for the remaining rows. Finally, we replace the original value column with the amplified values using the assignment operator. The updated dataframe with amplified rows is then displayed. You can adjust the date range and amplification factor to suit your specific needs.
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值