vendredi 20 février 2015

loop with variable in sqlite3

I'm using SQLite Expert Personal 3 to access and write sql script for sqlite databases. I have 30 sqlite databases that have same structure that i want to merge. im using the following script.The main database has id as auto increment.



attach 'database0001.db3' as toimport;
insert into [main].[Titles] select * from [toimport].[Titles];
insert into [main].[TitlesData] select * from [toimport].[TitlesData];
DETACH DATABASE toimport;


I can easily also create a database with the file names if its necessary.


Can this be done in a loop where a $variable is the name of file so i don't have to write same script 30 times?


Thank you and excuse the noob question :)


Aucun commentaire:

Enregistrer un commentaire