SQLite Forum

Renaming a database
Login
It's never, ever generically safe to rename an in-use sqlite3 file.

Windows won't let you rename an in-use file and in Unix if you rename an in-file file, anyone who has that file handle open is still using the old file handle (which may misbehave if the file is moved to a different filesystem and therefore gets a new inode - i'm not actually sure what happens in that case).

sqlite uses the file's name for creating various temporary files, e.g. the write-ahead log, and renaming a db file will cause a mismatch there.

In order to safely rename an sqlite db, it must not currently be opened by *any* clients.