Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:06:00+00:00 2026-06-10T23:06:00+00:00

I am creating a sqlite database in temp folder. Now I want to copy

  • 0

I am creating a sqlite database in temp folder. Now I want to copy that file to another folder. Is there any sqlite command to rename the sqlite database file?

I tried using rename function in c++ but it returns error 18. Error no 18 means: “The directory containing the name newname must be on the same file system as the file (as indicated by the name oldname)”.

Can someone suggest a better way to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:06:01+00:00Added an answer on June 10, 2026 at 11:06 pm

    Use a temporary directory on the correct filesystem!

    First, sqlite database is just a file. It can be moved or copied around whatever you wish, provided that:

    • It was correctly closed last time, so there would be no stuff to roll-back in the journal
    • If it uses write-ahead log type of journal, it is fully checkpointed.

    So moving it as a file is correct. Now there are two ways to move a file:

    • Using the rename system call.
    • By copying the file and deleting the old one.

    The former has many advantages: it can’t leave partially written file around, it can’t leave both files around , it is very fast and if you use it to rename over old file, there is no period where the target name wouldn’t exist (the last is POSIX semantics and Windows can do it on NTFS, but not FAT filesystem). It also has one important disadvantage: it only works within the filesystem. So you have to:

    • If you are renaming it to ensure that a partially written file is not left behind in case the process fails, you need to use rename and thus have to use a temporary location on the same filesystem. Often this is done by using different name in the same directory instead of using temporary directory.
    • If you are renaming it because the destination might be slow, e.g. because you want to put it on a network share, you obviously want to use temporary directory on different filesystem. That means you have to read the file and write it under the new name. There is no function for this in the standard C or C++ library, but many libraries will have one (and high-level languages like python will have one and you can always just execute /bin/mv to do it for you).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an iphone app that will run an SQLite database. I want
I am creating a web application that is accessing a SQLite database in the
I am creating a system that will store objects in an SQLite Database. I
I'm creating an app that has a database using sqlite. On my app I've
I am creating an application in Flex that uses an embedded SQLite database. The
i am creating an app that needs a database. i created it using sqlite
I have a SQLite database that I am creating in my iOS application. A
I am creating desktop application in winform that will use Sqlite Database. So I
I have a choice of either creating a new SqLite Database or add another
I am using sqlite database in Android. I'm not creating any database I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.