Oracle SQL to find tables hierarchy in a schema
<p>I have a need to import some data for a given input from multiple table's and schema's based on a key.</p>

<p>For-Ex: I have ACCOUNT_ID COLUMN which is common to multiple tables (tables are interdependent with FK). I want to import data for a specific account from all the tables from multiple schema's and generate a SQL script.</p>

<p>But the challenge is, I need to identify parent table's first and then their child table's (tied with FK) in the order so that when I run the script, it shouldn't error out with integrity violation errors.</p>

<p>One way is to disable all the constraints, generate the script, run and then enable the constraints.</p>

<p>But I am trying to find if there's a better way of doing this. And enabling/disabling the constraints may not be a good solution for me.</p>

<p>Appreciate any inputs on this issue. </p>