Using the C API, I don't see a way to determine the foreign key constraints for a named table?
Given this example:
CREATE TABLE artist(
artistid INTEGER PRIMARY KEY,
artistname TEXT
);
CREATE TABLE track(
trackid INTEGER,
trackname TEXT,
trackartist INTEGER,
FOREIGN KEY(trackartist) REFERENCES artist(artistid)
);
sqlite3_table_column_metadata() will tell you it's a primary key, autoincrement, etc. but how do I get the foreign key constraints?
FOREIGN KEY(trackartist) REFERENCES artist(artistid)
I want to be able to get a list back for table "track" that there are foreign keys back to table Artist column artistid?
I don't see an api to do this? I need to do this programmaticlly upon opening the database, for purposes of aggregation.
Thanks.
After using PRAGMA foreign_key_list(Valuation);
I got back:
PRAGMA foreign_key_list(Valuation);
0|0|Stock|StockId|Id|NO ACTION|NO ACTION|NONE
I understand I need to split on the vertical bar, but what are the first two columns? 0|0 ?