Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 sqlite3 数据库上运行一些ALTER TABLE语句。如果用户在 ALTER TABLE 运行时终止进程或断电会发生什么?数据库是否会处于损坏的中间状态?
从文档中的交易页面:
SQLite 中单个事务中的所有更改要么完全发生,要么根本不发生,即使将更改写入磁盘的行为被中断 * a program crash, * an operating system crash, or * a power failure.
SQLite 中单个事务中的所有更改要么完全发生,要么根本不发生,即使将更改写入磁盘的行为被中断
* a program crash, * an operating system crash, or * a power failure.
从文档的另一页:
任何更改数据库的命令(基本上是除 SELECT 之外的任何 SQL 命令)如果尚未生效,则将自动启动事务。当最后一个查询完成时,自动启动的事务被提交。
结合这些,答案是否定的。您的数据库不会在电源故障期间损坏。