How to list tables in their dependency order (based on foreign keys)?
问题 This question was originally asked by @PrateekGupta Background @PrateekGupta wanted to perform bulk insert operation on multiple tables. The tables have foreign key relationships between themselves. If an INSERT operation is done on a table with a foreign key before the referenced table is being inserted to, the operation might fail due to violation of the foreign key. Requirement Produce a list of tables within a database ordered according to their dependencies. Tables with no dependencies