How to export only specified records

Hello,

is it possible to export only specified records from the database? In my database there are different kind of vaults that user can have, and each table has the ID that shows to what vault records belongs to. How it would be possible to export/import only specific vault (only tables via specified ID)?

Thanks

Hello @cjacky - you can use ATTACH for this. Start off by attaching a new database to the current connection with a key. Create the desired schema in the new database, and then you can insert into the export database from a select on the main database. Here is a brief example.

ATTACH DATABASE 'export.db' AS export KEY 'keymaterial';
CREATE TABLE export.records(col1, col2);
INSERT INTO export.records(col1, col2) SELECT col1, col2 FROM maintable WHERE id IN (....);
DETACH DATABASE export;
1 Like