简体   繁体   English

批量更新所有行

[英]Bulk Update all rows sqlite

I'm new to Sqlite and I have a 15GB database. 我是Sqlite的新手,我有一个15GB的数据库。 I need to update all rows in column "filename" in 2 of the tables such that the filename is truncated. 我需要更新表2中“文件名”列中的所有行,以使文件名被截断。 Table 1 has 50,000 rows and Table 2 has 25 million rows. 表1有50,000行,表2有2500万行。

I know the update command for sqlite but I want to find out if using this is advisable in terms of the time it will take and things that can go wrong. 我知道sqlite的update命令,但我想根据时间和可能出错的情况来确定是否建议使用此命令。
I plan to use these commands: 我计划使用以下命令:

UPDATE users SET filename=substr(filename,15)
UPDATE people SET filename=substr(filename,15)

Specifically: 特别:

  1. How long will this take? 这需要多长时间?
  2. Should my computer have some minimum configuration for it to work well? 我的计算机是否应该具有一些最低配置才能正常运行?
  3. Is there a way for me to undo my update in case things go 有什么办法可以撤消我的更新,以防万一
    horribly wrong like version control? 像版本控制一样严重错误?
  4. Are there better ways out there of changing all rows in a sqlite database? 是否有更好的方法来更改sqlite数据库中的所有行?

Thank you so much! 非常感谢!

Rewriting everything will take a long time. 重写所有内容将花费很长时间。

You do not need much memory (although more helps for caching), but you need enough disk space for both the old and new data. 您不需要太多的内存(尽管更多的缓存帮助),但是您需要足够的磁盘空间来存储新旧数据。

By default, SQLite uses automatic transactions, which prevent partial changes when some statement is interrupted in the middle, but commits at the end of each statement. 默认情况下,SQLite使用自动事务处理,当某些语句在中间中断但在每个语句的末尾提交时,这会防止部分更改。 To be able to check the changes and to commit or roll them back later, use an explicit transaction . 为了能够检查更改并在以后提交或回滚它们,请使用显式事务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM