I have a SQLite database that makes use of foreign keys, some of which will be autoincremented values. The "core" data the system represents is for example a car. The foreign keys are linking to information about wheels and tires for example, and I wish to export n cars from one database and import into another.

I want to do this by writing a set of sql statements (i.e a bunch of insert statements) that can be loaded by the importing database, but the key values in the dumped data will not necessarily match up with the existing data (maybe there are duplicates in some of the key values).

What is the best way to deal with this? Is there an easy or recommended way to write the import script so that dependencies on exported key values are removed?

and then there's DDL

I want it, I want to make sure anybody else here thinks it helps us more. I think it's more than just "how do I write this SQL" because it's about the method of writing a correct set of queries for exporting the data.

  • you want that migrated to dba? remember we try to avoid migrations in beta until a site us public, except in exceptional cases. Mar 11, 2011 at 9:13
  • 2
    @Jeff ~ I meant in the sense of do we want to welcome those questions over here. Remember, we're trying to define our community, yes? So the more concensus we have "this is good, this is not good" the better. It would be nice to goto SO and offer the user to cross post to see if better answers can be had here. I understand not migrating, but there's also a definitive distinction in regards to asking them to cross-post. ~~~ takeaway: site definition by example.
    – jcolebrand Mod
    Mar 11, 2011 at 15:27
  • well said. I think we should update over faq based on these suggestions What kind of questions are allowed on Database Administrators ? Mar 14, 2011 at 20:10

1 Answer 1


I think, it is OK for dba..stackexchange. Focus is not on programming.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .