/* Show all foreign keys and referenced table/column */ /* Performing a cartesian join between sqlite_master and pragma_foreign_key_list function */ SELECT sm.name AS table_name, fk."from" AS column_name, 'FOREIGN KEY' AS constraint_type, fk."table" AS ref_table_name, fk."to" AS ref_column_name FROM sqlite_master sm JOIN pragma_foreign_key_list(sm.name) fk ORDER BY 1,2;