<p>I am trying to build a dependency graph of tables based on the foreign keys between them.  This graph needs to start with an arbitrary table name as its root.  I could, given a table name look up the tables that reference it using the all_constraints view, then look up the tables that reference them, and so on, but this would be horrible inefficient.  I wrote a recursive query that does this for all tables, but when I add:</p>

<pre><code>START WITH Table_Name=:tablename
</code></pre>

<p>It doesn't return the entire tree.</p>

Simplest way to do this is to copy all the FK info into a simple, 2-column (parent,child) table, and then use the following algorithm:
```
```
while (rows left in that table)
  list = rows where table name exists in child but not in parent
  print list
  remove list from rows
```
```
that's all. Basically, you first print and remove all the nodes that don't depend on anything. After that being done, some other nodes will get free and you can repeat process.
P.S. Make sure you don't insert self-referencing tables in the initial list (child=parent)