now that is awesome...

Of course, I first attempted it on SQLiteStudio using its 3.15 version of
sqlite. Looks like it missed it by one major release level; documentation
says it arrived as of 3.16.

I've tried it on my CLI version, which is 3.19+.

Good stuff. Thanks, Simon.

Regards.

Brian P Curley



On Fri, Feb 23, 2018 at 1:44 PM, Simon Slavin <slav...@bigfraud.org> wrote:

> On 23 Feb 2018, at 6:28pm, Brian Curley <bpcur...@gmail.com> wrote:
>
> > If there's pragmas like table_info available...can these be made
> available
> > for parsing, or used as virtual tables for selection, etc?
>
> In current versions of SQLite, you can use the results of PRAGMAs as if
> they are tables.  See the "PRAGMA functions" section of
>
> <https://sqlite.org/pragma.html>
>
> For example, information about the columns in an index can be read using
> the index_info pragma as follows:
>
> sqlite> CREATE TABLE members (name TEXT COLLATE NOCASE,
>                               phone TEXT COLLATE NOCASE,
>                               weekrank INTEGER,
>                               yearrank INTEGER);
> sqlite> CREATE INDEX m_ry ON members (yearrank, weekrank);
> sqlite> .headers ON
> sqlite> .mode column
> sqlite> PRAGMA index_info(m_ry);
> seqno       cid         name
> ----------  ----------  ----------
> 0           3           yearrank
> 1           2           weekrank
>
> The same content can be read using a SELECT command:
>
> sqlite> SELECT * FROM pragma_index_info('m_ry');
> seqno       cid         name
> ----------  ----------  ----------
> 0           3           yearrank
> 1           2           weekrank
>
> And, as with any other SELECT, you can modify the way the results are
> returned in the SELECT command ...
>
> sqlite> SELECT * FROM pragma_index_info('m_ry') ORDER BY cid;;
> seqno       cid         name
> ----------  ----------  ----------
> 1           2           weekrank
> 0           3           yearrank
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to