Here’s a quick tip if you want to keep a “schema” or “template” table on your database that you’ll then duplicate to populate with arbitrary data. This system works for collection of files where a particular table could represent a specific drive or medium, just as an example of the many uses it can have.
CREATE TABLE 'new_table' AS SELECT * FROM 'schema'; -- where 'schema' is our template table. |
This is basic SQL, but if you were to look up how to duplicate a Sqlite table you may come up short if you aren’t aware of standard SQL. As an exercise, here’s how Sqlite interprets the CREATE command.
A few restrictions could be applied to your SELECT statement, this will depend on your particular requirements.
As always, don’t forget to sanitize every input and when possible, remove user interaction altogether from the query — specially during the construction phase.
Cheers