On 4 January 2013 05:35, Petite Abeille <petite.abei...@gmail.com> wrote: > > On Jan 3, 2013, at 10:19 AM, nospam.nospam.nos...@gmail.com wrote: > >> I'm trying to create two queries so I can determine which of the keys >> for a given sqlite3 table is the primary key and which keys are >> foreign. > > pragma table_info() returns a 'pk' attribute. You can use that to identify > the primary keys. > > pragma index_list() returns a 'unique' attribute. You can use that to > identify the unique keys. > > pragma foreign_key_list() lists, well, the foreign keys themselves. > > FWIW, bellow is an attempt to build an information schema [1] out of the > various SQLite pragmas:
danap and Petite, thank you both kindly for all the in-depth information, and especially the links. Your efforts are appreciated as they have given me a much better understanding. I see now that I should be able to determine a PK and a unique key. As for FKs, unless I find some tidbit hidden in the pages you kindly linked to, or I decide to parse the SQL that created the table, then I will have to treat FKs just like any other key. I also searched google using some new keywords you both used and there is a lot more information out there for me to read. Once again, thank you. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users