Dienstag, 1. Dezember 2015

Selecting the schema of a Sqlite database

The interactive Sqlite command line tool offers the command .schema to read the Schema of a database. This works fine, but of course it is not a valid SQL query. The following query returns the whole schema in one string and is a valid SQL query.
SELECT group_concat(sql, ';' || char(10)) || ';'
FROM sqlite_master
WHERE name NOT LIKE 'sqlite_%';

Keine Kommentare: