til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Emulate database schemas using SQLite

Attempting to emulate Oracle in SQLite is a daunting task, but you can accomplish some success. If you do not have “public synonyms” or use multiple schemas, you can emulate this in SQLite by attaching several databases or even the database itself using the following command:

attach database 'sqlite.db' as MYOTHERSCHEMA;

You can get an overview of your databases (schemas) using the command:

.databases

When attaching a secondary database, you might get this error message.

"cannot ATTACH database within transaction"

You need to wrap the actual attaching in a transaction and it will work

BEGIN; attach database 'othersqlite.db'; END;

References