Hello,
I discovered the great 'genfkey' tool with the last release (3.6.4).
And I tried to customize it such as the output is not "CREATE TRIGGER"
statements but
"SELECT" statements.
Indeed, my SQLite database is populated from a MySQL dump and is not modified
afterwards.
The order of record insertion prevents me from using triggers.
So I replaced the original zSql string with:
const char *zSql =
"SELECT multireplace('"
"SELECT DISTINCT /rkey_list/, ''/tbl/(/rkey_list/)'' FROM /tbl/ tbl WHERE
\n"
" /key_notnull/ AND NOT EXISTS (SELECT 1 FROM /ref/ ref WHERE
/cond1/);\n"
"'"
", '/tbl/', from_tbl"
", '/ref/', to_tbl"
", '/key_notnull/', sj('tbl.' || from_col || ' IS NOT NULL', ' AND ')"
", '/fkey_list/', sj(to_col, ', ')"
", '/rkey_list/', sj(from_col, ', ')"
", '/cond1/', sj(multireplace('tbl./from/ == ref./to/'"
", '/from/', from_col"
", '/to/', to_col"
"), ' AND ')"
") FROM temp.fkey "
"GROUP BY from_tbl, fkid"
;
And now I'd like to check that, for all foreign keys, there is an associated
index.
Is it feasible?
Regards.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users