title: How to run postgres sql script from another script?
body: <p>I have a bunch of SQL scripts that create tables in the database. Each table is located in a separate file so that editing them is much easier.</p>
  
  <p>I wanted to prepare a single SQL script that will create the full schema, create tables, insert test data and generate sequences for the tables.</p>
  
  <p>I was able to do such thing for oracle database but I am having problems with postgres.
  The thing is - I do not know how to run the table creating script from another script.</p>
  
  <p>In oracle I do it using the following syntax:</p>
  
  <pre><code>@@'path of the script related to the path of the currently running sql file'
  </code></pre>
  
  <p>And everything works like a charm.</p>
  
  <p>In postgres I was trying to search for something alike and found this:</p>
  
  <pre><code>\ir 'relative path to the file'
  </code></pre>
  
  <p>Unfortunately when I run my main script I get the message:</p>
  
  <pre><code>No such file or directory.
  </code></pre>
  
  <p>The example call is here:</p>
  
  <pre><code>\ir './tables/map_user_groups.sql'
  </code></pre>
  
  <p>I use Postgres 9.3. I tried to run the script using psql:</p>
  
  <pre><code>psql -U postgres -h localhost -d postgres &lt; "path to my main sql file"
  </code></pre>
  
  <p>The file executes fine except for the calling of those other scripts.</p>
  
  <p>Does anybody know how to solve the problem ?</p>
  
  <p>If something in the question is unclear - just let me know :)</p>