Kyle
Kyle

Reputation: 17677

sqlite3 table_info for a view. what table does the column come from?

When I run:

PRAGMA table_info(myView)

It gives me a list, similar to:

0|cardSet|CHAR(255)|0||0
1|multiverseId|INTEGER|0||0
2|cardSetId|INTEGER|0||0
3|name|CHAR(255)|0||0
4|type|CHAR(16)|0||0
5|cost|nvarchar(16)|0||0
6|color|nvarchar(16)|0||0
7|rarity|nvarchar(16)|0||0

But from this I have no details on what table those columns are actually in. I was thinking of using a regular expression to try and figure this out, but was wondering if anyone knew of an alternative?

Upvotes: 1

Views: 254

Answers (1)

CL.
CL.

Reputation: 180010

It is possible to have columns that originate from multiple tables, or from no table at all:

CREATE VIEW example AS
SELECT a.a1, b.b1, a.a2 + b.b2 AS both, 42 AS neither FROM a, b;

In any case, SQLite does not store this information so that it can be accessed directly. All you can read is the original view definition:

SELECT sql FROM sqlite_master WHERE type = 'view' AND name = 'myView'

Upvotes: 1

Related Questions